Toggle option for powering monitor on and off. #724
Replies: 2 comments
-
You could make a script that checks the current state in
Output mirroring isn't implemented in niri itself yet and it is quite complex to implement too, so probably not in the near future. You can use wl-mirror though. |
Beta Was this translation helpful? Give feedback.
-
@deadbody13 I have been working on this and I can share what I have (atm): # Functions that depend on the window manager
exists_display() { niri msg --json outputs | jq --exit-status --arg DISPLAY "$1" '.[$DISPLAY]' > /dev/null; }
is_display_on() { niri msg --json outputs | jq --exit-status --arg DISPLAY "$1" '.[$DISPLAY] | .current_mode' > /dev/null; }
toggle() { exists_display "$1" && niri msg output "$1" "$2"; }
# Utility functions
profile_internal_name() { echo -n "Internal display"; }
profile_internal_valid() { exists_display eDP-1; }
profile_internal_set() { toggle HDMI-A-1 off && toggle eDP-1 on; }
profile_external_name() { echo -n "External display"; }
profile_external_valid() { exists_display HDMI-A-1; }
profile_external_set() { toggle eDP-1 off && toggle HDMI-A-1 on; }
profile_extend_name() { echo -n "Extend displays"; }
profile_extend_valid() { exists_display "eDP-1" && exists_display "HDMI-A-1"; }
profile_extend_set() { toggle eDP-1 on && toggle HDMI-A-1 on; }
DEFAULT="$(profile_internal_name)"
# shellcheck disable=SC2005
options() {
profile_internal_valid && echo "$(profile_internal_name)"
profile_external_valid && echo "$(profile_external_name)"
profile_extend_valid && echo "$(profile_extend_name)"
}
dmenu() {
options | fuzzel --dmenu --placeholder "Current: ${DEFAULT}" --lines 3
}
# FIXME
notify() {
notify-send "Display layout" "Set to ..."
}
case "$(dmenu)" in
"$(profile_internal_name)") profile_internal_set && notify ;;
"$(profile_external_name)") profile_external_set && notify ;;
"$(profile_extend_name)") profile_extend_set && notify ;;
esac The only thing missing from me is having a way to (separately) detect when the HDMI cable is disconnected. The Edit: I went a different route. |
Beta Was this translation helpful? Give feedback.
-
When I play games, watch a movie, or just want a single monitor to focus on something I've been going into the config and add
off
to one of the monitor output sections to make it so only one screen is on. It reduces ambient light and helps me focus.It'd be cool to have a command that I can bind to toggle a monitor between on and off so I didn't have to go into the config to do so. Something like:
Or maybe a way to pipe this into fuzzel so that we have a Windows-esque Primary Only, Secondary Only, Extend, and Duplicate option.
Beta Was this translation helpful? Give feedback.
All reactions