Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: recipe for using rofi as menu for way-displays #140

Closed
jeadorf opened this issue Nov 19, 2023 · 7 comments
Closed

Feature: recipe for using rofi as menu for way-displays #140

jeadorf opened this issue Nov 19, 2023 · 7 comments

Comments

@jeadorf
Copy link

jeadorf commented Nov 19, 2023

rofi

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)

@jeadorf
Copy link
Author

jeadorf commented Nov 19, 2023

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.

@jeadorf
Copy link
Author

jeadorf commented Nov 19, 2023

The following example

rofi-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

@alex-courtis
Copy link
Owner

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 ;)

@jeadorf
Copy link
Author

jeadorf commented Nov 20, 2023 via email

@alex-courtis
Copy link
Owner

Added to the recipes.

@jeadorf
Copy link
Author

jeadorf commented Dec 18, 2023

Sorry for sitting on this so long ... https://github.com/alex-courtis/way-displays/wiki/Recipes looks good. Thank you!

@alex-courtis
Copy link
Owner

No worries; please do update it as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants