rofi: Fix powermenu searchstring display
Since switching to `dash` as the default sh shell, rofi would display ostensibly hidden strings (like comment tags, or rofi meta options). This is due to this bug https://github.com/davatorium/rofi/issues/1201 or behavior of dash. Could be possibly fixed by using octal, for now, the script works with bash rather than sh (i.e. dash).
This commit is contained in:
parent
8fd025653a
commit
c71c553591
2 changed files with 69 additions and 53 deletions
|
@ -1,9 +1,11 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#### Environment Variable Options ###
|
#### Environment Variable Options ###
|
||||||
# Interface options
|
# Interface options
|
||||||
# ROFI_POWERMENU_SHOW_ICONS=1
|
# ROFI_POWERMENU_SHOW_ICONS=1
|
||||||
# ROFI_POWERMENU_SHOW_TEXT=0
|
# ROFI_POWERMENU_SHOW_TEXT=0
|
||||||
|
# ROFI_POWERMENU_SHOW_UPTIME=1
|
||||||
|
# ROFI_POWERMENU_SEARCHABLE=0
|
||||||
# Command options
|
# Command options
|
||||||
# ROFI_POWERMENU_SHUTDOWN_CMD=""
|
# ROFI_POWERMENU_SHUTDOWN_CMD=""
|
||||||
# ROFI_POWERMENU_REBOOT_CMD=""
|
# ROFI_POWERMENU_REBOOT_CMD=""
|
||||||
|
@ -29,48 +31,62 @@ if [ "${ROFI_POWERMENU_SHOW_TEXT:-0}" -eq 1 ]; then
|
||||||
suspend_btn="${suspend_btn} Suspend"
|
suspend_btn="${suspend_btn} Suspend"
|
||||||
logout_btn="${logout_btn} Log Out"
|
logout_btn="${logout_btn} Log Out"
|
||||||
fi
|
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} <!-- Shutdown Poweroff -->"
|
||||||
|
reboot_btn="${reboot_btn} <!-- Reboot Restart -->"
|
||||||
|
lock_btn="${lock_btn} <!-- Lockscreen -->"
|
||||||
|
suspend_btn="${suspend_btn} <!-- Suspend Sleep -->"
|
||||||
|
logout_btn="${logout_btn} <!-- Exit X Logout -->"
|
||||||
|
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 "$*" in
|
||||||
"Shutdown")
|
"Shutdown" | "$power_off_btn")
|
||||||
if [ -n "$ROFI_POWERMENU_SHUTDOWN_CMD" ]; then eval "$ROFI_POWERMENU_SHUTDOWN_CMD"; else
|
if [ -n "$ROFI_POWERMENU_SHUTDOWN_CMD" ]; then eval "$ROFI_POWERMENU_SHUTDOWN_CMD"; else
|
||||||
systemctl poweroff
|
systemctl poweroff
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"Reboot")
|
"Reboot" | "$reboot_btn")
|
||||||
if [ -n "$ROFI_POWERMENU_REBOOT_CMD" ]; then eval "$ROFI_POWERMENU_REBOOT_CMD"; else
|
if [ -n "$ROFI_POWERMENU_REBOOT_CMD" ]; then eval "$ROFI_POWERMENU_REBOOT_CMD"; else
|
||||||
systemctl reboot
|
systemctl reboot
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"Lockscreen")
|
"Lockscreen" | "$lock_btn")
|
||||||
# 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
|
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
|
fi
|
||||||
;;
|
;;
|
||||||
"Logout")
|
"Logout" | "$logout_btn")
|
||||||
if [ -n "$ROFI_POWERMENU_LOGOUT_CMD" ]; then eval "$ROFI_POWERMENU_LOGOUT_CMD"; else
|
if [ -n "$ROFI_POWERMENU_LOGOUT_CMD" ]; then eval "$ROFI_POWERMENU_LOGOUT_CMD"; else
|
||||||
i3-msg exit
|
i3-msg exit
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"Suspend")
|
"Suspend" | "$suspend_btn")
|
||||||
if [ -n "$ROFI_POWERMENU_SUSPEND_CMD" ]; then eval "$ROFI_POWERMENU_SUSPEND_CMD"; else
|
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 hibernate
|
# systemctl hibernate
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$*" ]; then
|
if [ "${ROFI_POWERMENU_SHOW_UPTIME:-1}" -eq 1 ]; then
|
||||||
printf "\x00prompt\x1fPower> \n"
|
prompt="Uptime: $(uptime -p | sed -e 's/up //g')"
|
||||||
# we can use pango markup to hide text which we can then search. Neat!
|
else
|
||||||
printf "\0markup-rows\x1ftrue\n"
|
prompt="Power"
|
||||||
|
fi
|
||||||
printf "<!-- Shutdown Poweroff --> %s\n" "$power_off_btn"
|
|
||||||
printf "<!-- Reboot Restart --> %s\n" "$reboot_btn"
|
if [ -z "$*" ]; then
|
||||||
printf "<!-- Lockscreen --> %s\n" "$lock_btn"
|
printf "\0prompt\x1f%s\n" "$prompt"
|
||||||
printf "<!-- Suspend Sleep --> %s\n" "$suspend_btn"
|
printf "\0markup\x1ftrue\n"
|
||||||
printf "<!-- Exit X Logout --> %s\n" "$logout_btn"
|
|
||||||
|
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
|
fi
|
||||||
|
|
|
@ -8,7 +8,7 @@ super + x
|
||||||
|
|
||||||
# Open System Power Menu
|
# Open System Power Menu
|
||||||
super + BackSpace
|
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
|
# quick-switching of theme using styler
|
||||||
super + F8
|
super + F8
|
||||||
|
|
Loading…
Reference in a new issue