about summary refs log tree commit diff
path: root/home/profiles/gui/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'home/profiles/gui/scripts')
-rw-r--r--home/profiles/gui/scripts/aeroplane-mode.nix12
-rw-r--r--home/profiles/gui/scripts/scratchpad-indicator.nix18
2 files changed, 23 insertions, 7 deletions
diff --git a/home/profiles/gui/scripts/aeroplane-mode.nix b/home/profiles/gui/scripts/aeroplane-mode.nix
index 9f09c05..0b1ecf3 100644
--- a/home/profiles/gui/scripts/aeroplane-mode.nix
+++ b/home/profiles/gui/scripts/aeroplane-mode.nix
@@ -1,15 +1,13 @@
 ''
 set -euo pipefail
 
-rfkill_soft=$(rfkill -ro soft | tail -n +2 | sort -u)
+radio_status=$(nmcli radio | tail -n +2 | awk 'OFS="\n" {print $2,$4}' | sort -u)
 
-rfkill toggle all
-
-if [[ $rfkill_soft == "unblocked"  ]]; then
+if [[ $radio_status == "enabled" ]]; then
+    nmcli radio all off
     notify-send --urgency=critical "Aeroplane mode ACTIVATED"
-elif [[ $rfkill_soft == "blocked" ]]; then
-    notify-send --urgency=critical "Aeroplane mode DEACTIVATED"
 else
-    notify-send --urgency=critical "WARN: RFKill was in inconsistent state. Aeroplane mode ACTIVATED"
+    nmcli radio all on
+    notify-send --urgency=low "Aeroplane mode DEACTIVATED"
 fi
 ''
diff --git a/home/profiles/gui/scripts/scratchpad-indicator.nix b/home/profiles/gui/scripts/scratchpad-indicator.nix
new file mode 100644
index 0000000..7ee66c3
--- /dev/null
+++ b/home/profiles/gui/scripts/scratchpad-indicator.nix
@@ -0,0 +1,18 @@
+''
+output="$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.name == "__i3_scratch").floating_nodes[]|"`<b>"+.name+"`</b> - "+.app_id+" "+(.id|tostring)')"
+number="$(swaymsg -r -t get_tree | jq -r 'recurse(.nodes[]) | first(select(.name=="__i3_scratch")) | .floating_nodes | length')"
+
+if [ "$number" -gt 0 ]; then
+    text="$number"
+else
+    text=""
+fi
+
+output="$(echo "$output" | sed -r 's/[&]+/and/g')" # Replace unprintable & character with the word 'and'
+tooltip="Scratchpad\n\n"
+tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')"
+tooltip=''${tooltip::-2}
+
+echo "{\"text\":\"$text\", \"tooltip\":\"$tooltip\"}"
+exit 0
+''