From 3cc907dde5689032e26915e3a75cc2504a8aa5f0 Mon Sep 17 00:00:00 2001 From: Out Of Ideas Date: Mon, 25 Mar 2024 13:01:04 -0500 Subject: [PATCH] Hello Unixporn --- eww/eww.yuck | 2 +- eww/scripts/.brightness-off | 2 +- eww/scripts/.previous-volume | 2 +- eww/scripts/toggle-brightness.sh | 18 ++++++++++++++++++ fuzzel/scripts/powermenu.sh | 15 +++++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100755 fuzzel/scripts/powermenu.sh diff --git a/eww/eww.yuck b/eww/eww.yuck index 6fb38f7..c666efd 100644 --- a/eww/eww.yuck +++ b/eww/eww.yuck @@ -75,7 +75,7 @@ ;(metric :label "" ; :value {EWW_CPU.avg} ; :onchange "") - (button :class "powermenu" :onclick "echo" ""))) + (button :class "powermenu" :onclick "~/.config/fuzzel/scripts/powermenu.sh" ""))) ;; monitor 0 (defwidget workspaces_monitor_0 [] diff --git a/eww/scripts/.brightness-off b/eww/scripts/.brightness-off index 27ba77d..c508d53 100644 --- a/eww/scripts/.brightness-off +++ b/eww/scripts/.brightness-off @@ -1 +1 @@ -true +false diff --git a/eww/scripts/.previous-volume b/eww/scripts/.previous-volume index 4b9026d..3ad5abd 100644 --- a/eww/scripts/.previous-volume +++ b/eww/scripts/.previous-volume @@ -1 +1 @@ -63 +99 diff --git a/eww/scripts/toggle-brightness.sh b/eww/scripts/toggle-brightness.sh index b6c36e6..23afbd2 100755 --- a/eww/scripts/toggle-brightness.sh +++ b/eww/scripts/toggle-brightness.sh @@ -1,19 +1,37 @@ #!/bin/sh +# The Brightness (Before Turning Brightness Off) STATUS_FILE="$HOME/.config/eww/scripts/.previous-brightness" +# Whether or not Brightness is Currently Off STATUS_FILE2="$HOME/.config/eww/scripts/.brightness-off" +# The Brightness when Pressing the Button BRIGHTNESS=$(brightnessctl | head -2 | tail +2 | awk '{print $4}' | tr -cd '[[:digit:]]') +# If Brightness is Turned off, +# Then Set the Brightnes to the +# Brightness at the time the Brightness was Turned Off if $(cat $STATUS_FILE2); then doas /usr/bin/brightnessctl s $(cat $STATUS_FILE)% + # Then Update the Value that is seen by Eww (Eww will now display than amount) eww update brightness=$(cat $STATUS_FILE) + # If Eww Does not think think that the brightness is zero, + # Then make sure that the minimum slider width is 7px. + # If The Brightness (Before Turning Brighness off is zero, then leave the slider empty. if [ $(eww get brightness) -ne 0 ]; then eww update metric-brightness="non-zero" fi + # The Brightness is no longer turned off. + # Next time the button is pressed, the other path will be taken. echo false > $STATUS_FILE2 + # If Brightness is not off, turn it off else eww update brightness=0 + # Make the slider empty eww update metric-brightness="zero" + # Send the Brightness when pressing the button to the status file, + # so that the program sets that value next time. echo $BRIGHTNESS > $STATUS_FILE + # Tell the program that Brightness is Turned Off echo true > $STATUS_FILE2 + # Set the Brightness to 0 doas /usr/bin/brightnessctl s 0% fi diff --git a/fuzzel/scripts/powermenu.sh b/fuzzel/scripts/powermenu.sh new file mode 100755 index 0000000..b1d8a64 --- /dev/null +++ b/fuzzel/scripts/powermenu.sh @@ -0,0 +1,15 @@ +#!/bin/sh +LAUNCHER_CMD="fuzzel --dmenu" +OPTIONS="$(echo -e "exit\nreboot\npoweroff")" + +SELECTED_OPTION=$(echo "$OPTIONS" | $LAUNCHER_CMD) + +if $(test "$SELECTED_OPTION" = "exit"); then + hyprctl dispatch exit +elif $(test "$SELECTED_OPTION" = "reboot"); then + doas /sbin/reboot +elif $(test "$SELECTED_OPTION" = "poweroff"); then + doas /sbin/poweroff +else + set -e +fi