Added power confirmation script

This commit is contained in:
DIvan2000 2025-02-16 22:38:25 +04:00
parent 80b82e8d86
commit 84fdfab431
2 changed files with 17 additions and 5 deletions

10
config
View File

@ -18,7 +18,7 @@
"disable-scroll": true,
"all-outputs": false,
"active-only": false,
"show-special": true,
"show-special": false,
"format": "{name}"
},
"hyprland/window": {
@ -109,15 +109,15 @@
},
"modules": [
"custom/power", // First element is the "group leader" and won't ever be hidden
"custom/exit",
"custom/lock",
"custom/exit",
"custom/reboot",
]
},
"custom/exit": {
"format": " 󰗼 ",
"tooltip": false,
"on-click": "hyprctl dispatch exit"
"on-click": "bash ~/.config/waybar/scripts/confirm.sh \"hyprctl dispatch exit\""
},
"custom/lock": {
"format": " 󰍁 ",
@ -127,11 +127,11 @@
"custom/reboot": {
"format": " 󰜉 ",
"tooltip": false,
"on-click": "reboot"
"on-click": "bash ~/.config/waybar/scripts/confirm.sh \"reboot\""
},
"custom/power": {
"format": "  ",
"tooltip": false,
"on-click": "shutdown now"
"on-click": "bash ~/.config/waybar/scripts/confirm.sh \"shutdown now\""
}
}

12
scripts/confirm.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
ACTION=$1
LOCKFILE="/tmp/confirm_$(echo -n $ACTION | md5sum | awk '{print $1}')"
if [ -f "$LOCKFILE" ]; then
rm "$LOCKFILE"
$ACTION
else
touch "$LOCKFILE"
notify-send "Нажмите ещё раз для подтверждения" -t 5000 -w
rm "$LOCKFILE"
fi