Make rofi-powermenu configurable through env vars
Added Environment variables to show/hide the text and icons, as well as change the individual commands rofi-powermenu uses to affect the system.
This commit is contained in:
parent
49cacfe787
commit
ff6ca7e684
1 changed files with 43 additions and 12 deletions
|
@ -1,34 +1,65 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#### User Options ###
|
#### Environment Variable Options ###
|
||||||
|
# Interface options
|
||||||
|
# ROFI_POWERMENU_SHOW_ICONS=1
|
||||||
|
# ROFI_POWERMENU_SHOW_TEXT=0
|
||||||
|
# Command options
|
||||||
|
# ROFI_POWERMENU_SHUTDOWN_CMD=""
|
||||||
|
# ROFI_POWERMENU_REBOOT_CMD=""
|
||||||
|
# ROFI_POWERMENU_LOCKSCREEN_CMD=""
|
||||||
|
# ROFI_POWERMENU_LOGOUT_CMD=""
|
||||||
|
# ROFI_POWERMENU_SUSPEND_CMD=""
|
||||||
|
|
||||||
#### Menu Options ###
|
#### Menu Options ###
|
||||||
|
if [ "${ROFI_POWERMENU_SHOW_TEXT:-0}" -eq 0 ] && [ "${ROFI_POWERMENU_SHOW_ICONS:-1}" -eq 0 ]; then
|
||||||
|
echo "You disabled both text and icons for rofi-powermenu, nothing can be shown."
|
||||||
|
exit 1
|
||||||
|
elif [ "${ROFI_POWERMENU_SHOW_ICONS:-1}" -eq 1 ]; then
|
||||||
power_off_btn=""
|
power_off_btn=""
|
||||||
reboot_btn=""
|
reboot_btn=""
|
||||||
lock_btn=""
|
lock_btn=""
|
||||||
suspend_btn="鈴"
|
suspend_btn="鈴"
|
||||||
logout_btn=""
|
logout_btn=""
|
||||||
|
fi
|
||||||
|
if [ "${ROFI_POWERMENU_SHOW_TEXT:-0}" -eq 1 ]; then
|
||||||
|
power_off_btn="${power_off_btn} Shut Down"
|
||||||
|
reboot_btn="${reboot_btn} Restart"
|
||||||
|
lock_btn="${lock_btn} Lock Screen"
|
||||||
|
suspend_btn="${suspend_btn} Suspend"
|
||||||
|
logout_btn="${logout_btn} Log Out"
|
||||||
|
fi
|
||||||
|
|
||||||
# grep -a since it assumes with our nullcodes etc that this is a binary file
|
# grep -a since it assumes with our nullcodes etc that this is a binary file
|
||||||
# grep -o to only leave the things we grep for
|
# grep -o to only leave the things we grep for
|
||||||
case $(echo "$*" | grep -a -o -e "Shutdown" -e "Reboot" -e "Lockscreen" -e "Logout" -e "Suspend") in
|
case $(echo "$*" | grep -a -o -e "Shutdown" -e "Reboot" -e "Lockscreen" -e "Logout" -e "Suspend") in
|
||||||
"Shutdown")
|
"Shutdown")
|
||||||
|
if [ -n "$ROFI_POWERMENU_SHUTDOWN_CMD" ]; then eval "$ROFI_POWERMENU_SHUTDOWN_CMD"; else
|
||||||
systemctl poweroff
|
systemctl poweroff
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"Reboot")
|
"Reboot")
|
||||||
|
if [ -n "$ROFI_POWERMENU_REBOOT_CMD" ]; then eval "$ROFI_POWERMENU_REBOOT_CMD"; else
|
||||||
systemctl reboot
|
systemctl reboot
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"Lockscreen")
|
"Lockscreen")
|
||||||
# Completely detach from the parent script
|
# Completely detach from the parent script
|
||||||
# If in/outputs are not redirected, rofi will wait for the forked process as well.
|
# If in/outputs are not redirected, rofi will wait for the forked process as well.
|
||||||
|
if [ -n "$ROFI_POWERMENU_LOCKSCREEN_CMD" ]; then eval "$ROFI_POWERMENU_LOCKSCREEN_CMD"; else
|
||||||
lockscreen rofi </dev/null >/dev/null 2>/dev/null &
|
lockscreen rofi </dev/null >/dev/null 2>/dev/null &
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"Logout")
|
"Logout")
|
||||||
|
if [ -n "$ROFI_POWERMENU_LOGOUT_CMD" ]; then eval "$ROFI_POWERMENU_LOGOUT_CMD"; else
|
||||||
i3-msg exit
|
i3-msg exit
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"Suspend")
|
"Suspend")
|
||||||
|
if [ -n "$ROFI_POWERMENU_SUSPEND_CMD" ]; then eval "$ROFI_POWERMENU_SUSPEND_CMD"; else
|
||||||
lockscreen rofi </dev/null >/dev/null 2>/dev/null &
|
lockscreen rofi </dev/null >/dev/null 2>/dev/null &
|
||||||
systemctl suspend
|
systemctl suspend
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue