commit e65159a362a4abc1230152d136945d6cc3ddff61 Author: Dejvino Date: Sun Feb 21 17:15:25 2021 +0100 Initial diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a3a84d --- /dev/null +++ b/README.md @@ -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! + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..b78f527 Binary files /dev/null and b/screenshot.png differ diff --git a/stickynote b/stickynote new file mode 100755 index 0000000..d53dee3 --- /dev/null +++ b/stickynote @@ -0,0 +1,4 @@ +#!/bin/bash + +termite -e "sway_stickynotes ask" + diff --git a/sway_stickynotes b/sway_stickynotes new file mode 100755 index 0000000..70b6e1c --- /dev/null +++ b/sway_stickynotes @@ -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 +