From 198fa8e9cb94527733e09bc1b04c878320079520 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Fri, 20 Feb 2026 15:40:27 +0100 Subject: Refactor waybar/hyprland --- roles/hyprland/files/scripts/bluetooth.sh | 49 ++++++++++++++++++++++++++++++ roles/hyprland/files/scripts/brightness.sh | 2 +- roles/hyprland/files/scripts/launch-tui | 3 ++ roles/hyprland/files/scripts/sunset.sh | 4 +-- roles/hyprland/files/scripts/volume.sh | 4 +-- roles/hyprland/files/scripts/wifi.sh | 49 ++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 5 deletions(-) create mode 100755 roles/hyprland/files/scripts/bluetooth.sh create mode 100755 roles/hyprland/files/scripts/launch-tui create mode 100755 roles/hyprland/files/scripts/wifi.sh (limited to 'roles/hyprland/files/scripts') diff --git a/roles/hyprland/files/scripts/bluetooth.sh b/roles/hyprland/files/scripts/bluetooth.sh new file mode 100755 index 00000000..7f276df4 --- /dev/null +++ b/roles/hyprland/files/scripts/bluetooth.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +turn_on() { + rfkill unblock bluetooth + bluetoothctl power on + notify "on" +} + +turn_off() { + rfkill unblock bluetooth + bluetoothctl power off + notify "off" +} + +toggle() { + if bluetoothctl <<< show | grep -q "Powered: yes"; then + turn_off + else + turn_on + fi +} + +notify() { + local class="$1" + notify-send -e \ + -h string:x-canonical-private-synchronous:bluetooth \ + -u low \ + "Bluetooth" \ + " ${class}" +} + +case "$1" in + "--on") + turn_on + ;; + "--off") + turn_off + ;; + "--toggle") + toggle + ;; + *) + echo -e "Usage:" + echo -e " --on to turn bluetooth on" + echo -e " --off to turn bluetooth off" + echo -e " --toggle to toggle bluetooth state" + exit 0 + ;; +esac diff --git a/roles/hyprland/files/scripts/brightness.sh b/roles/hyprland/files/scripts/brightness.sh index 1d935f28..7489d9d9 100755 --- a/roles/hyprland/files/scripts/brightness.sh +++ b/roles/hyprland/files/scripts/brightness.sh @@ -89,7 +89,7 @@ notify() { -h string:x-canonical-private-synchronous:brightness-"$serial" \ -u low \ "Brightness" \ - " $name: ${value}%" + " $name: ${value}%" } STEP="${2:-1}" diff --git a/roles/hyprland/files/scripts/launch-tui b/roles/hyprland/files/scripts/launch-tui new file mode 100755 index 00000000..16efba9b --- /dev/null +++ b/roles/hyprland/files/scripts/launch-tui @@ -0,0 +1,3 @@ +#!/bin/bash + +exec setsid uwsm-app -- alacritty --class="work.kartoffln.$(basename "$1")" -e "$@" diff --git a/roles/hyprland/files/scripts/sunset.sh b/roles/hyprland/files/scripts/sunset.sh index 52f3ea7c..1659aaab 100755 --- a/roles/hyprland/files/scripts/sunset.sh +++ b/roles/hyprland/files/scripts/sunset.sh @@ -51,8 +51,8 @@ notify() { notify-send -e \ -h string:x-canonical-private-synchronous:sunset \ -u low \ - "${icon} Nightshift ${class}" \ - "Temprature: ${temp}" + "Nightshift ${class}" \ + "${icon} Temprature: ${temp}" } TEMP="${2:-$TEMP_ON}" diff --git a/roles/hyprland/files/scripts/volume.sh b/roles/hyprland/files/scripts/volume.sh index 5c2ad3d5..d2168ce1 100755 --- a/roles/hyprland/files/scripts/volume.sh +++ b/roles/hyprland/files/scripts/volume.sh @@ -44,13 +44,13 @@ notify() { -h string:x-canonical-private-synchronous:volume \ -u low \ "$label" \ - "$mute_icon\tmute" + "$mute_icon mute" else notify-send -e \ -h string:x-canonical-private-synchronous:volume \ -u low \ "$label" \ - "$icon\t${value}%" + "$icon ${value}%" fi } diff --git a/roles/hyprland/files/scripts/wifi.sh b/roles/hyprland/files/scripts/wifi.sh new file mode 100755 index 00000000..838d03a8 --- /dev/null +++ b/roles/hyprland/files/scripts/wifi.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +turn_on() { + rfkill unblock wifi + nmcli radio wifi on + notify "on" +} + +turn_off() { + nmcli radio wifi off + rfkill unblock wifi + notify "off" +} + +toggle() { + if nmcli radio wifi | grep -q "enabled"; then + turn_off + else + turn_on + fi +} + +notify() { + local class="$1" + notify-send -e \ + -h string:x-canonical-private-synchronous:wifi \ + -u low \ + "Wifi" \ + "󰖩 ${class}" +} + +case "$1" in + "--on") + turn_on + ;; + "--off") + turn_off + ;; + "--toggle") + toggle + ;; + *) + echo -e "Usage:" + echo -e " --on to turn wifi on" + echo -e " --off to turn wifi off" + echo -e " --toggle to toggle wifi state" + exit 0 + ;; +esac -- cgit v1.2.3