aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2024-02-19 22:32:41 +0000
committerLeonardo Bishop <me@leonardobishop.com>2024-02-19 22:32:41 +0000
commit977a459ddaa33a856255be9c15464f0a5937c06c (patch)
tree9f4b2b86a0863fda1d8eebae05b1c99df1cf7af1
parent373891b492424c64ba8071affd38801a057e35ef (diff)
Add scripts to repo
-rwxr-xr-xbin/battery-notify.sh37
-rwxr-xr-xbin/exit-menu.sh18
-rwxr-xr-xbin/hyprctl-zoom-daemon.sh40
-rwxr-xr-xbin/hyprctl-zoom.sh15
-rwxr-xr-xbin/swayidle.sh6
-rw-r--r--hyprland/binds.conf2
-rw-r--r--hyprland/startup.conf4
7 files changed, 119 insertions, 3 deletions
diff --git a/bin/battery-notify.sh b/bin/battery-notify.sh
new file mode 100755
index 0000000..ed07119
--- /dev/null
+++ b/bin/battery-notify.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+last="NONE"
+
+low=15
+critical=5
+
+bat="BAT1"
+
+while true; do
+
+ battery="/sys/class/power_supply/$bat"
+ if [ -d $battery ]; then
+
+ capacity=$(cat $battery/capacity)
+ status=$(cat $battery/status)
+
+ if [ "$last" != "FULL" ] && [ "$status" = "Full" ]; then
+ notify-send "Power" "Battery is full"
+ last="FULL"
+ fi
+
+ # If low and discharging
+ if [ "$last" != "LOW" ] && [ "$status" = "Discharging" ] && \
+ [ $capacity -le $low ]; then
+ notify-send "Power" "Battery warning: $capacity%"
+ last=LOW
+ fi
+
+ # If critical and discharging
+ if [ "$status" = "Discharging" ] && [ $capacity -le $critical ]; then
+ notify-send "Power" "Battery critical: $capacity%"
+ last=CRITICAL
+ fi
+ fi
+ sleep 60
+done
diff --git a/bin/exit-menu.sh b/bin/exit-menu.sh
new file mode 100755
index 0000000..763007e
--- /dev/null
+++ b/bin/exit-menu.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+entries=" Lock\n󰹆 Suspend\n󰍃 Logout\n󰜉 Reboot\n󰐥 Shutdown"
+
+selected=$(echo -e $entries|wofi --width 100 --height 185 --dmenu --cache-file /dev/null --define content_halign=center --define prompt="Exit menu" | awk '{print tolower($2)}')
+
+case $selected in
+ lock)
+ swaylock;;
+ logout)
+ hyprctl dispatch exit;;
+ suspend)
+ exec systemctl suspend;;
+ reboot)
+ exec systemctl reboot;;
+ shutdown)
+ exec systemctl poweroff -i;;
+esac
diff --git a/bin/hyprctl-zoom-daemon.sh b/bin/hyprctl-zoom-daemon.sh
new file mode 100755
index 0000000..7752279
--- /dev/null
+++ b/bin/hyprctl-zoom-daemon.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+zoom=1
+
+izoom () {
+ if [ $(echo "scale=0;$zoom/1" | bc) -eq 4 ];
+ then
+ zoom=4
+ return
+ fi
+ zoom=$(echo "$zoom + 0.2" | bc)
+}
+
+dzoom () {
+ if [ $(echo "scale=0;$zoom/1" | bc) -eq 0 ];
+ then
+ zoom=1
+ return
+ fi
+ zoom=$(echo "$zoom - 0.2" | bc)
+}
+
+while :
+do
+ message=$(nc -lU /tmp/hyprctl-zoom.sock)
+ case $message in
+ plus)
+ izoom
+ hyprctl keyword misc:cursor_zoom_factor $zoom
+ ;;
+ minus)
+ dzoom
+ hyprctl keyword misc:cursor_zoom_factor $zoom
+ ;;
+ *)
+ echo "Invalid message received"
+ ;;
+ esac
+done
+
diff --git a/bin/hyprctl-zoom.sh b/bin/hyprctl-zoom.sh
new file mode 100755
index 0000000..5970ec0
--- /dev/null
+++ b/bin/hyprctl-zoom.sh
@@ -0,0 +1,15 @@
+#/bin/bash
+
+case $1 in
+ i)
+ echo "plus" | nc -NU /tmp/hyprctl-zoom.sock
+ ;;
+ d)
+ echo "minus" | nc -NU /tmp/hyprctl-zoom.sock
+ ;;
+ *)
+ echo "Usage: $0 [id]"
+ exit 1
+ ;;
+esac
+
diff --git a/bin/swayidle.sh b/bin/swayidle.sh
new file mode 100755
index 0000000..8b971f7
--- /dev/null
+++ b/bin/swayidle.sh
@@ -0,0 +1,6 @@
+exec swayidle -w \
+ timeout 300 "notify-send 'Power' 'System will suspend soon due to inactivity'" \
+ timeout 310 "swaylock" \
+ timeout 315 "systemctl suspend" \
+ before-sleep "swaylock"
+
diff --git a/hyprland/binds.conf b/hyprland/binds.conf
index 39ee7c8..4165398 100644
--- a/hyprland/binds.conf
+++ b/hyprland/binds.conf
@@ -9,7 +9,7 @@ bind = $mainMod, Return, exec, alacritty
bind = $mainMod, Q, killactive,
bind = $mainMod SHIFT, Space, togglefloating,
bind = $mainMod, D, exec, pgrep -x wofi >/dev/null 2>&1 && killall wofi || wofi --show drun
-bind = $mainMod SHIFT, E, exec, ~/.config/hypr/exit-menu.sh
+bind = $mainMod SHIFT, E, exec, ~/bin/exit-menu.sh
# Move around
bind = $mainMod, H, movefocus, l
diff --git a/hyprland/startup.conf b/hyprland/startup.conf
index dc1a665..f98eb35 100644
--- a/hyprland/startup.conf
+++ b/hyprland/startup.conf
@@ -7,10 +7,10 @@ env = WLR_NO_HARDWARE_CURSORS,1
exec-once = waybar
exec-once = hyprpaper
exec-once = mako
-exec-once = ~/.config/hypr/swayidle.sh
-exec-once = /usr/lib/polkit-kde-authentication-agent-1
exec-once = easyeffects --gapplication-service
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
+exec-once = /usr/lib/polkit-kde-authentication-agent-1
+exec-once = ~/bin/swayidle.sh
exec-once = ~/bin/battery-notify.sh
exec-once = ~/bin/hyprctl-zoom-daemon.sh
#exec-once = systemd-inhibit --what=handle-power-key sleep infinity