Created
July 3, 2025 13:31
-
-
Save ildar/ef351cdf65e5b00c834fe7a36f75f59f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Manual power manager :-\ | |
command="$1" | |
delay=${2:-infinite} | |
set -euo pipefail | |
state=off | |
if systemd-inhibit --list | grep -q wayland_pm; then | |
state=on | |
fi | |
# shellcheck disable=SC3010 | |
if [[ "$command" == "toggle_inhibit" ]]; then | |
if [[ "$state" == off ]]; then | |
systemd-inhibit \ | |
--who=wayland_pm \ | |
--why="script initiated" \ | |
--mode=block \ | |
sleep $delay >&2 & | |
else | |
pid=$(systemd-inhibit --list | grep wayland_pm) | |
pid=${pid// / } | |
pid=${pid#*"$USER" } | |
pid=${pid%% *} | |
kill $pid | |
fi | |
exit 0 | |
fi | |
# shellcheck disable=SC3010 | |
if [[ "$command" == "status_inhibit" ]]; then | |
if [[ "$state" == off ]]; then | |
echo "inhibit off" | |
else | |
echo "inhibit on" | |
fi | |
exit 0 | |
fi | |
# shellcheck disable=SC3010 | |
if [[ "$command" == "status_inhibit_icon" ]]; then | |
if [[ "$state" == off ]]; then | |
echo "💤" | |
else | |
echo "🍵" | |
fi | |
exit 0 | |
fi | |
swayidle timeout 55 "light -O ; light -S 10" resume "light -I" & | |
swayidle timeout 65 "gtklock -b ~/.local/share/wallpapers/locksreen-bg.jpg" before-sleep "gtklock -b ~/.local/share/wallpapers/locksreen-bg.jpg" & | |
swayidle timeout 300 "LANG=C upower -i /org/freedesktop/UPower/devices/line_power_AC | grep online | egrep -q no$ && systemctl suspend" & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to use in ironbar add this to your config: