Script works when run from terminal emulator, but not when run from waybar. #3588
-
I have a module which looks like: "custom/power": {
"format" : "⏻ ",
"tooltip": false,
"on-click": "/home/amberwing/.config/sway/power-menu.sh"
} and a partially unfinished script if [ $1 ]; then
echo -en "\
Usage: $(basename $0) [argument]
Displays a tofi menu to select a power option.
Nerd Fonts icons are used. A font can be downloaded at:
https://www.nerdfonts.com/
Dependencies: systemctl, tofi.
"
exit
fi
list () {
suspend_message=" Suspend"
logoff_message=" Logout"
shutdown_message=" Shutdown"
reboot_message=" Reboot"
printf "$suspend_message\n$logoff_message\n$shutdown_message\n$reboot_message"
}
chosen=$(printf "$(list)" | tofi --prompt-text="Select:")
echo $chosen
if [ -z "$chosen" ]; then
exit
elif [[ "$chosen" =~ ^ ]]; then
systemctl suspend
else
exit
fi This script opens a tofi menu with Suspend/Logoff/Shutdown/Reboot options. Currently, only the suspend option is implemented and it works when run from a terminal, but it does not work when run from Waybar. It's probably a permissions thing, but this is my first time using anything other than a desktop environment, so I have no experience in this beyond chmod +x. I'm using this on Sway on Ubuntu. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This was entirely my fault not remotely Waybar's at all. Apparently What I did was run waybar from the terminal, and saw that when I ran the script, I got Before you laugh, this is my first time writing a script like this. I cannot believe this is what fixed it. Jesus Christ. Basically what happened was, I saw the |
Beta Was this translation helpful? Give feedback.
This was entirely my fault not remotely Waybar's at all. Apparently
#!/bin/bash
is required to be the first line in a bash script. Go figure, I guess.What I did was run waybar from the terminal, and saw that when I ran the script, I got
/home/amberwing/.config/sway/power-menu.sh: 25: [[: not found
, so I looked at the other script I had (downloaded from the Internet, slightly modified), and noticed the#!/bin/bash
thing.Before you laugh, this is my first time writing a script like this. I cannot believe this is what fixed it. Jesus Christ.
Basically what happened was, I saw the
#!/bin/bash
line and assumed it was some weird comment. This is what I get for my way of diving in head first w…