Feature: recipe for using rofi as menu for way-displays
jeadorf opened this issue · 7 comments
A beautiful TUI to manage displays. Would you care to share your setup / configuration? That would be the start of the Recipes wiki page.
Originally posted by @alex-courtis in #121 (comment)
I'm using rofi (https://github.com/davatorium/rofi, https://wiki.archlinux.org/title/rofi), together with a customized rust program driving the interactive menu, displayed by rofi. In order to make the recipes more self-contained and thus useful (minimal dependencies), I need to post some examples on how to use rofi and way-displays with the least amount of customization. But once you get the gist on how rofi works, should be fairly straight-forward to include shortcuts to way-displays like the ones in the screenshot.
The following example
allows user to switch between internal only, external only, or both displays.
#/bin/sh
# Configure names of external and internal displays
EXTERNAL="HDMI-A-1"
INTERNAL="eDP-1"
function show() {
way-displays --delete DISABLED "$1" > /dev/null
}
function hide() {
way-displays -s DISABLED "$1" > /dev/null
}
OPT_INTERNAL="Internal display"
OPT_EXTERNAL="External display"
OPT_BOTH="Both displays"
function menu() {
echo "${OPT_INTERNAL}"
echo "${OPT_EXTERNAL}"
echo "${OPT_BOTH}"
}
OPTION=$( (menu) | rofi -dmenu -p "Configure displays")
# Invoke way-displays. Only hide a display if showing the other display
# succeeded. This reduces the chances to end up with both displays turned off,
# which is typically rather inconvenient.
if [ "${OPTION}" == "${OPT_INTERNAL}" ]
then
show "${INTERNAL}" && hide "${EXTERNAL}"
elif [ "${OPTION}" == "${OPT_EXTERNAL}" ]
then
show "${EXTERNAL}" && hide "${INTERNAL}"
elif [ "${OPTION}" == "${OPT_BOTH}" ]
then
show "${EXTERNAL}"
show "${INTERNAL}"
fi
- I wrote this script using the example from https://github.com/davatorium/rofi-scripts/blob/master/i3_switch_workspace.sh.
- It is relatively straight-forward to include other shortcuts to configure the display
- rofi has various themes, I included a screenshot of the default theme
That is just fantastic! Thank you so much.
I've moved things to a wiki, with a recipes page.
I'd be most grateful if you could add you recipe in there - you should get the credit ;)
Added to the recipes.
Sorry for sitting on this so long ... https://github.com/alex-courtis/way-displays/wiki/Recipes looks good. Thank you!
No worries; please do update it as needed.