diff --git a/rofi/.config/rofi/modes/powermenu b/rofi/.config/rofi/modes/powermenu index 9bac8fb..2ad8526 100755 --- a/rofi/.config/rofi/modes/powermenu +++ b/rofi/.config/rofi/modes/powermenu @@ -1,9 +1,11 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash #### Environment Variable Options ### # Interface options # ROFI_POWERMENU_SHOW_ICONS=1 # ROFI_POWERMENU_SHOW_TEXT=0 +# ROFI_POWERMENU_SHOW_UPTIME=1 +# ROFI_POWERMENU_SEARCHABLE=0 # Command options # ROFI_POWERMENU_SHUTDOWN_CMD="" # ROFI_POWERMENU_REBOOT_CMD="" @@ -13,64 +15,78 @@ #### 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 + 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="" - reboot_btn="" - lock_btn="" - suspend_btn="鈴" - logout_btn="" + power_off_btn="" + reboot_btn="" + lock_btn="" + suspend_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" + 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 +# FIXME does not hide pango comments anymore for some reason +if [ "${ROFI_POWERMENU_SEARCHABLE:-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 # 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 -case $(echo "$*" | grep -a -o -e "Shutdown" -e "Reboot" -e "Lockscreen" -e "Logout" -e "Suspend") in -"Shutdown") - if [ -n "$ROFI_POWERMENU_SHUTDOWN_CMD" ]; then eval "$ROFI_POWERMENU_SHUTDOWN_CMD"; else - systemctl poweroff - fi - ;; -"Reboot") - if [ -n "$ROFI_POWERMENU_REBOOT_CMD" ]; then eval "$ROFI_POWERMENU_REBOOT_CMD"; else - systemctl reboot - fi - ;; -"Lockscreen") - # Completely detach from the parent script - # 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 2>/dev/null & - fi - ;; -"Logout") - if [ -n "$ROFI_POWERMENU_LOGOUT_CMD" ]; then eval "$ROFI_POWERMENU_LOGOUT_CMD"; else - i3-msg exit - fi - ;; -"Suspend") - if [ -n "$ROFI_POWERMENU_SUSPEND_CMD" ]; then eval "$ROFI_POWERMENU_SUSPEND_CMD"; else - lockscreen rofi /dev/null 2>/dev/null & - systemctl hibernate - fi - ;; +case "$*" in +"Shutdown" | "$power_off_btn") + if [ -n "$ROFI_POWERMENU_SHUTDOWN_CMD" ]; then eval "$ROFI_POWERMENU_SHUTDOWN_CMD"; else + systemctl poweroff + fi + ;; +"Reboot" | "$reboot_btn") + if [ -n "$ROFI_POWERMENU_REBOOT_CMD" ]; then eval "$ROFI_POWERMENU_REBOOT_CMD"; else + systemctl reboot + fi + ;; +"Lockscreen" | "$lock_btn") + # Completely detach from the parent script + # 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 2>/dev/null & + fi + ;; +"Logout" | "$logout_btn") + if [ -n "$ROFI_POWERMENU_LOGOUT_CMD" ]; then eval "$ROFI_POWERMENU_LOGOUT_CMD"; else + i3-msg exit + fi + ;; +"Suspend" | "$suspend_btn") + if [ -n "$ROFI_POWERMENU_SUSPEND_CMD" ]; then eval "$ROFI_POWERMENU_SUSPEND_CMD"; else + lockscreen rofi /dev/null 2>/dev/null & + # systemctl hibernate + fi + ;; esac -if [ -z "$*" ]; then - printf "\x00prompt\x1fPower> \n" - # we can use pango markup to hide text which we can then search. Neat! - printf "\0markup-rows\x1ftrue\n" - - printf " %s\n" "$power_off_btn" - printf " %s\n" "$reboot_btn" - printf " %s\n" "$lock_btn" - printf " %s\n" "$suspend_btn" - printf " %s\n" "$logout_btn" +if [ "${ROFI_POWERMENU_SHOW_UPTIME:-1}" -eq 1 ]; then + prompt="Uptime: $(uptime -p | sed -e 's/up //g')" +else + prompt="Power" +fi + +if [ -z "$*" ]; then + printf "\0prompt\x1f%s\n" "$prompt" + printf "\0markup\x1ftrue\n" + + printf "%s\n" "$power_off_btn" + printf "%s\n" "$reboot_btn" + printf "%s\n" "$lock_btn" + printf "%s\n" "$suspend_btn" + printf "%s\n" "$logout_btn" + printf "\0markup-rows\x1ftrue\n" fi diff --git a/sxhkd/.config/sxhkd/sxhkdrc b/sxhkd/.config/sxhkd/sxhkdrc index c199b87..942a6b7 100644 --- a/sxhkd/.config/sxhkd/sxhkdrc +++ b/sxhkd/.config/sxhkd/sxhkdrc @@ -8,7 +8,7 @@ super + x # Open System Power Menu super + BackSpace - rofi -modi "powermenu:~/.config/rofi/modes/powermenu" -show powermenu -theme themes/powermenu + rofi -modi "powermenu:~/.config/rofi/modes/powermenu" -show powermenu -theme themes/powermenu -selected-row 2 # quick-switching of theme using styler super + F8