Hi,
I have this keybind to spawn a powermenu based on dmenu and slock
Maybe that should be in the default config ?
FYI. loginctl should be available on the overwhelming majority of linux distros because it is provided by both systemd and elogind which are the most widely used init systems
[[keybind]]
command = "Execute"
value = '''
#!/bin/sh
case "$(echo -e "Shutdown\nRestart\nLogout\nSuspend\nHibernate\nLock" | dmenu \
-nb "${COLOR_BACKGROUND:-#151515}" \
-nf "${COLOR_DEFAULT:-#aaaaaa}" \
-sf "${COLOR_HIGHLIGHT:-#589cc5}" \
-sb "#1a1a1a" \
-b -i -p \
"Power:" -l 6)" in
Shutdown) exec loginctl poweroff;;
Restart) exec loginctl reboot;;
Logout) exec loginctl kill-session $XDG_SESSION_ID;;
Suspend) exec loginctl suspend;;
Hibernate) exec loginctl hibernate;;
Lock) exec slock;;
esac
'''
modifier = ["modkey", "Control"]
key = "p"
I like this idea.
I just would try to keep things in the default config as minimal as possible for pure functionality and try to leave colours etc. to the theme if possible.
Also I would suggest to use Super + 0 as keybind as I believe this more common for a power/logout-menu, isn't it?
Also I would suggest to use Super + 0 as keybind as I believe this more common for a power/logout-menu, isn't it?
I actually have no idea, I just went with Super + Ctrl + p because it was the closest to the other dmenu related default keybind (Super + p = dmenu_run). This guy uses Super + Shift + Q for the powermenu. And distrotube uses (Super + P + KEY) for dmenu scripts
I just would try to keep things in the default config as minimal as possible for pure functionality and try to leave colours etc. to the theme if possible
This is the original script that I copied, I tried playing around with the flags that he passes to the dmenu command, it didn't go too well lol, tho I am not a dmenu expert. The original script seems to mimic the looks of dmenu_run, feel free to play around with it ! :)
If it is accepted, probably should gate it behind both dmenu and loginctl being installed. If someone new wants to tackle it, see https://github.com/leftwm/leftwm/blob/2b6e9cf8688984a03a0396c045a7f671800f942a/src/config.rs#L128 for one way how to do that.
I don't like this because it would essentially create a dependency on dmenu and systemd. Maybe that's not a big deal, but it doesn't seem necessary.
If a power menu is felt to be a desired feature, I would suggest creating an abstraction that would recognize a handful of reasonable executors of the menu commands: dmenu, rofi, ulauncher, or some generic command enum variant. So something like
enum Launcher {
Dmenu,
Rofi,
Ulauncher,
Other(String),
None
}
You could add the launcher as an optional field to config.toml. If launcher is None then the power menu is not initiated. Alternatively you could handle it the same way as terminals, iterating over a list of terminals and using the first one found on the system.
Most helpful comment
If it is accepted, probably should gate it behind both dmenu and loginctl being installed. If someone new wants to tackle it, see https://github.com/leftwm/leftwm/blob/2b6e9cf8688984a03a0396c045a7f671800f942a/src/config.rs#L128 for one way how to do that.