Hello Unixporn

This commit is contained in:
Out Of Ideas 2024-03-25 13:01:04 -05:00
parent c5d23666a5
commit 3cc907dde5
5 changed files with 36 additions and 3 deletions

View File

@ -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 []

View File

@ -1 +1 @@
true
false

View File

@ -1 +1 @@
63
99

View File

@ -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

15
fuzzel/scripts/powermenu.sh Executable file
View File

@ -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