Stickynotes assigned to Sway workspaces.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

48 lignes
1.0 KiB

  1. #!/bin/bash
  2. NOTESDIR=~/.config/sway_stickynotes
  3. WORKSPACE=`swaymsg -t get_workspaces -p | grep \(focused\) | cut -f2 -d " "`
  4. function print_usage {
  5. echo "Usage: $0 CMD [VAL]"
  6. echo " CMD ... command: get / set / ask"
  7. echo " get ... returns the current value"
  8. echo " set ... set a new value"
  9. echo " ask ... show a dialog to update the current value"
  10. echo " VAL ... value set when CMD == 'set'"
  11. }
  12. function show_dialog {
  13. CMD=$0
  14. TEMPFILE=~/.config/sway_stickynotes/note
  15. mkdir -p `dirname $TEMPFILE`
  16. $CMD get > $TEMPFILE
  17. dialog --inputbox "Updated stickynote:" 10 30 "`cat $TEMPFILE`" 2> $TEMPFILE
  18. VAL=`cat $TEMPFILE`
  19. $CMD set "$VAL"
  20. }
  21. mkdir -p $NOTESDIR
  22. if [ $1 == "-h" ] || [ $1 == "--help" ]; then
  23. print_usage
  24. exit 0
  25. elif [[ $1 == "get" ]]; then
  26. VAL=`cat $NOTESDIR/$WORKSPACE 2>/dev/null`
  27. echo $VAL
  28. exit 0
  29. elif [[ $1 == "set" ]]; then
  30. shift 1
  31. echo "$@" > $NOTESDIR/$WORKSPACE
  32. exit 0
  33. elif [ $1 == "ask" ]; then
  34. show_dialog
  35. else
  36. print_usage
  37. exit 1
  38. fi