Skip to content

Commit

Permalink
added drag and drop clipboard example
Browse files Browse the repository at this point in the history
  • Loading branch information
druskus20 committed Apr 18, 2022
1 parent dcb4fb7 commit 6c22be6
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ The different [eww](https://github.com/elkowar/eww) configs that I've been makin
Workspace Indicator
</p>

<p align="center">
<img src="drag-drop-clipboard/.github/preview.gif">
<br>
Drag and Drop Clipboard
</p>

<p align="center">
<img src="revealer-example/.github/preview.gif">
<br>
Expand Down
Binary file added drag-drop-clipboard/.github/preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions drag-drop-clipboard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Drag and Drop Clipboard

This is a proof-of-concept for a drag and drop clipboard area.

NOTE: This example makes use of the `loop_widget` and `droptarget` branches

<p align="center">
<img src=".github/preview.gif">
</p>
17 changes: 17 additions & 0 deletions drag-drop-clipboard/eww.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
* {
all: unset;
}

.clipboard {
background-color: #707070;
padding: 10px;
}

.files {
background-color: blue;
margin: 10px;
}
.file {
margin: 10px;
background-color: green;
}
32 changes: 32 additions & 0 deletions drag-drop-clipboard/eww.yuck
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; Note: there are definitely some rough edges here, this is just a proof of concept

(defwindow bar
:monitor 0
:geometry (geometry :anchor "top left" :x 350 :y 50 :width "200px" :height "100px")
(box :class "top"
(clipboard)))

(defvar file_list "")

(defwidget clipboard []
(eventbox
:class "clipboard"
;:ondropped "${eww_command} update tmp_value={}"
:ondropped "./update-file-list.py {}"
:dragvalue {file_list}
(files :file_list file_list)))


(defwidget files [file_list]
(box :class "files"
(for f in file_list
(file :file f))))


(defwidget file [file]
(eventbox :class "file"
:ondropped "./update-file-list.py {}"
:dragvalue {file}
(label :text file)))


29 changes: 29 additions & 0 deletions drag-drop-clipboard/update-file-list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/python3

import sys
import subprocess
import json
from io import StringIO

eww_files_var = "file_list"

# get "file_list" from eww
r = subprocess.run(['eww', 'get', eww_files_var], stdout=subprocess.PIPE)
io = StringIO(r.stdout.decode('utf-8'))

# try loading file_list as json or initialize a new empty list
try:
file_list = json.load(io)
except json.decoder.JSONDecodeError:
file_list = []

# if the file_list is full, pop one file from it
if len(file_list) >= 3:
file_list.pop(0)

# add the new file to the end of the list
new_file = sys.argv[1]
file_list.append(new_file)

# update eww's file_list
r = subprocess.run(['eww', 'update', eww_files_var+ '=' + json.dumps(file_list)])
2 changes: 2 additions & 0 deletions workspace-indicator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This is a new take on workspace indicators. It uses a background image for the big diamond at the bottom.

NOTE: This example makes use of the `loop_widget` branch

<p align="center">
<img src=".github/preview.png">
</p>

0 comments on commit 6c22be6

Please sign in to comment.