hyprland: quick and dirty screen mirroring
This commit is contained in:
parent
a0ae09452f
commit
9af362b5c8
@ -47,6 +47,24 @@ in {
|
|||||||
|
|
||||||
wf-recorder
|
wf-recorder
|
||||||
wl-clipboard
|
wl-clipboard
|
||||||
|
|
||||||
|
(pkgs.writeShellScriptBin
|
||||||
|
"toggle-screen-mirroring"
|
||||||
|
(builtins.readFile
|
||||||
|
./toggle-screen-mirroring.sh))
|
||||||
|
|
||||||
|
(
|
||||||
|
pkgs.writeShellScriptBin
|
||||||
|
"correct-workspace-locations"
|
||||||
|
(
|
||||||
|
lib.concatStringsSep "\n"
|
||||||
|
(
|
||||||
|
builtins.concatLists (
|
||||||
|
map (monitor: map (ws: "hyprctl dispatch moveworkspacetomonitor ${ws} ${monitor.name}") monitor.workspaces) config.monitors
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
services.cliphist = {
|
services.cliphist = {
|
||||||
@ -194,6 +212,7 @@ in {
|
|||||||
|
|
||||||
exec = [
|
exec = [
|
||||||
"hyprctl setcursor ${config.gtk.cursorTheme.name} ${toString config.gtk.cursorTheme.size}"
|
"hyprctl setcursor ${config.gtk.cursorTheme.name} ${toString config.gtk.cursorTheme.size}"
|
||||||
|
"correct-workspace-locations"
|
||||||
];
|
];
|
||||||
|
|
||||||
misc = {
|
misc = {
|
||||||
@ -269,7 +288,9 @@ in {
|
|||||||
"$mod SHIFT, E, exec, wlogout -p layer-shell"
|
"$mod SHIFT, E, exec, wlogout -p layer-shell"
|
||||||
"$mod, Escape, exec, wlogout -p layer-shell"
|
"$mod, Escape, exec, wlogout -p layer-shell"
|
||||||
"$mod SHIFT, R, exec, hyprctl reload"
|
"$mod SHIFT, R, exec, hyprctl reload"
|
||||||
|
"$mod, Print, exec, hyprshot-gui"
|
||||||
", Print, exec, hyprshot-gui"
|
", Print, exec, hyprshot-gui"
|
||||||
|
"$mod, P, exec, toggle-screen-mirroring; correct-workspace-locations"
|
||||||
|
|
||||||
# "$mod SHIFT, E, exec, pkill Hyprland"
|
# "$mod SHIFT, E, exec, pkill Hyprland"
|
||||||
# "$mod, G, togglegroup,"
|
# "$mod, G, togglegroup,"
|
||||||
|
66
homes/julian/features/hyprland/toggle-screen-mirroring.sh
Normal file
66
homes/julian/features/hyprland/toggle-screen-mirroring.sh
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
|
# A hyprland script for a laptop-external-monitor setup, toggling between which is in use
|
||||||
|
|
||||||
|
# Launch at startup to make hyprland disable the internal monitor if an external monitor is detected and enabled
|
||||||
|
# Additionally it's called with a keybind to switch between a laptop monitor and an external display
|
||||||
|
# Ideally the conditional monitor behaviour was instead done directly in hyprland.conf, but I'm not sure whether that's possible
|
||||||
|
#
|
||||||
|
# Relevant info:
|
||||||
|
# - hyprctl monitors: identifies currently enabled monitors
|
||||||
|
# - hyprctl monitors all: identifies ALL connected monitors - including those not in use
|
||||||
|
#
|
||||||
|
# Suggested use:
|
||||||
|
# Add this line somewhere after the regular monitor configuration in hyprland.conf:
|
||||||
|
# exec = /path/to/hyprland-monitors-toggle.sh
|
||||||
|
# Add a keybind to run this script on demand:
|
||||||
|
# bind =,SomeKeyHere, exec, /path/to/hyprland-monitors-toggle.sh
|
||||||
|
|
||||||
|
#move_all_workspaces_to_monitor() {
|
||||||
|
# TARGET_MONITOR="$1"
|
||||||
|
|
||||||
|
# hyprctl workspaces | grep ^workspace | cut --delimiter ' ' --fields 3 | xargs -I '{}' hyprctl dispatch moveworkspacetomonitor '{}' "$TARGET_MONITOR"
|
||||||
|
|
||||||
|
# # Previous approach
|
||||||
|
# #hyprctl swapactiveworkspaces $EXTERNAL_MONITOR $INTERNAL_MONITOR
|
||||||
|
#}
|
||||||
|
|
||||||
|
# TODO: Detect these instead of hardcoding them
|
||||||
|
INTERNAL_MONITOR="eDP-1"
|
||||||
|
EXTERNAL_MONITOR="HDMI-A-1"
|
||||||
|
|
||||||
|
# NUM_MONITORS=$(hyprctl monitors all | grep --count Monitor)
|
||||||
|
# NUM_MONITORS_ACTIVE=$(hyprctl monitors | grep --count Monitor)
|
||||||
|
|
||||||
|
# Make sure all
|
||||||
|
# if [ "$NUM_MONITORS_ACTIVE" -eq 1 ]; then
|
||||||
|
# move_all_workspaces_to_monitor $INTERNAL_MONITOR
|
||||||
|
# exit
|
||||||
|
# fi
|
||||||
|
|
||||||
|
MIRROR_SETTING=$(hyprctl monitors all -j | jq -r '.[] | select(.name == "HDMI-A-1") | .mirrorOf')
|
||||||
|
|
||||||
|
# # For dynamically toggling which monitor is active later via a keybind
|
||||||
|
# if [ "$NUM_MONITORS" -gt 1 ]; then # Handling multiple monitors
|
||||||
|
# if hyprctl monitors | cut --delimiter ' ' --fields 2 | grep --quiet ^$EXTERNAL_MONITOR; then
|
||||||
|
# hyprctl keyword monitor $INTERNAL_MONITOR,preferred,0x0,1
|
||||||
|
# move_all_workspaces_to_monitor $INTERNAL_MONITOR
|
||||||
|
# hyprctl keyword monitor "$EXTERNAL_MONITOR, disable"
|
||||||
|
# else
|
||||||
|
# hyprctl keyword monitor $EXTERNAL_MONITOR,preferred,0x0,1
|
||||||
|
# move_all_workspaces_to_monitor $EXTERNAL_MONITOR
|
||||||
|
# hyprctl keyword monitor "$INTERNAL_MONITOR, disable"
|
||||||
|
# fi
|
||||||
|
# else # If the external monitor is disconnected without running this script first, it might become the case that no monitor is on - therefore turn on the laptop monitor!
|
||||||
|
# hyprctl keyword monitor $INTERNAL_MONITOR,preferred,0x0,1
|
||||||
|
# move_all_workspaces_to_monitor $INTERNAL_MONITOR
|
||||||
|
# fi
|
||||||
|
|
||||||
|
echo setting:
|
||||||
|
echo $MIRROR_SETTING
|
||||||
|
if [ "$MIRROR_SETTING" = "none" ]; then
|
||||||
|
echo "mirroring..."
|
||||||
|
hyprctl keyword monitor "$EXTERNAL_MONITOR, preferred, auto, 1, mirror, $INTERNAL_MONITOR"
|
||||||
|
else
|
||||||
|
hyprctl keyword monitor "$EXTERNAL_MONITOR, preferred, auto, 1"
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user