add compatibility with dmenu

This commit is contained in:
Guilherme Rugai Freire 2021-06-28 08:17:58 -03:00
parent cff4456d98
commit 516cb35fc6
2 changed files with 12 additions and 3 deletions

View File

@ -4,7 +4,7 @@
## Installing shell-color-scripts
> Requires [rofi](https://github.com/davatorium/rofi)
> Requires [rofi](https://github.com/davatorium/rofi) or [dmenu](https://tools.suckless.org/dmenu/)
```sh
git clone https://github.com/GRFreire/simple-power-menu $HOME/.local/share/simple-power-menu

View File

@ -1,5 +1,14 @@
#!/usr/bin/env bash
if [[ $(command -v rofi) ]]; then
CMD='rofi -dmenu';
elif [[ $(command -v dmenu) ]]; then
CMD='dmenu';
else
echo 'Could not find either dmenu or rofi, exiting'
exit 0;
fi
fn_logout() {
if [[ $DESKTOP_SESSION =~ ^.*openbox$ ]]; then
openbox --exit
@ -35,7 +44,7 @@ PROMPT="${PROMPT%??}"
PROMPT_LENGHT="${#OPTIONS[@]}"
CHOICE=$(echo -e $PROMPT | rofi -dmenu -l $PROMPT_LENGHT -width 20 -p "Power Menu")
CHOICE=$(echo -e $PROMPT | $CMD -l $PROMPT_LENGHT -p "Power Menu")
if [[ -z $CHOICE ]]; then
exit 0;
@ -53,7 +62,7 @@ if [ $CAN_PROCEDE -eq 0 ]; then
fi
CONFIRMATION_CHOICES="no\nyes"
CONFIRMATION=$(echo -e $CONFIRMATION_CHOICES | rofi -dmenu -l 2 -width 20 -p "Do you want to $CHOICE")
CONFIRMATION=$(echo -e $CONFIRMATION_CHOICES | $CMD -l 2 -p "Do you want to $CHOICE")
if [ -z $CONFIRMATION ]; then
exit 0;