This commit is contained in:
Dejvino 2021-02-21 17:15:25 +01:00
commit e65159a362
4 changed files with 101 additions and 0 deletions

50
README.md Normal file
View File

@ -0,0 +1,50 @@
# Sway Stickynotes
Add a stickynote to your Sway workspace. This makes it easy to remember what you were doing on each workspace.
## Usage
- Execute `stickynote` via an application launcher (e.g. `dmenu` using Super+D)
- Edit the current workspace's stickynote text
- Enjoy the helpful stickynote!
![Screenshot](screenshot.png)
## Install
### Scripts
Core script:
```
sudo cp sway_stickynotes /usr/local/bin/
```
Dialog launcher, edit this one if you don't use `termite` as your terminal emulator:
```
sudo cp stickynote /usr/local/bin/
```
### Waybar configuration
#### ~/.config/waybar/config
```
...
"modules-left": [
"sway/workspaces",
"custom/stickynote"
],
...
"custom/stickynote": {
"exec": "sway_stickynotes get",
"interval": 1
},
```
#### ~/.config/waybar/style
```
#custom-stickynote {
background: #1f1f1f;
padding: 2px 10px;
border: 1px solid #333;
}
```
Done!

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

4
stickynote Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
termite -e "sway_stickynotes ask"

47
sway_stickynotes Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
NOTESDIR=~/.config/sway_stickynotes
WORKSPACE=`swaymsg -t get_workspaces -p | grep \(focused\) | cut -f2 -d " "`
function print_usage {
echo "Usage: $0 CMD [VAL]"
echo " CMD ... command: get / set / ask"
echo " get ... returns the current value"
echo " set ... set a new value"
echo " ask ... show a dialog to update the current value"
echo " VAL ... value set when CMD == 'set'"
}
function show_dialog {
CMD=$0
TEMPFILE=~/.config/sway_stickynotes/note
mkdir -p `dirname $TEMPFILE`
$CMD get > $TEMPFILE
dialog --inputbox "Updated stickynote:" 10 30 "`cat $TEMPFILE`" 2> $TEMPFILE
VAL=`cat $TEMPFILE`
$CMD set "$VAL"
}
mkdir -p $NOTESDIR
if [ $1 == "-h" ] || [ $1 == "--help" ]; then
print_usage
exit 0
elif [[ $1 == "get" ]]; then
VAL=`cat $NOTESDIR/$WORKSPACE 2>/dev/null`
echo $VAL
exit 0
elif [[ $1 == "set" ]]; then
shift 1
echo "$@" > $NOTESDIR/$WORKSPACE
exit 0
elif [ $1 == "ask" ]; then
show_dialog
else
print_usage
exit 1
fi