-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use systemd service to trigger select-display from udev
This change should help avoid freezing due to udev evoking the script too early.
- Loading branch information
Showing
2 changed files
with
59 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Discover connected displays | ||
scaling_pref=$(cat /var/lib/gui-localization/screen-scaling 2>/dev/null || echo "default") | ||
echo "Using scaling preference '$scaling_pref'" | ||
connected_outputs=$(xrandr | grep ' connected' | awk '{ print $1 }') | ||
echo "Connected outputs: $connected_outputs" | ||
if [ -z "$connected_outputs" ]; then | ||
echo "No connected outputs found. Trying to apply xrandr globally." | ||
case "$scaling_pref" in | ||
"default" | "full-hd") | ||
xrandr --size 1920x1080;; | ||
"native") | ||
xrandr --auto;; | ||
*) | ||
echo "Unknown scaling preference '$scaling_pref'. Applying auto."; | ||
xrandr --auto;; | ||
esac | ||
else | ||
for output in $connected_outputs; do | ||
echo "Enabling connected output $output" | ||
case "$scaling_pref" in | ||
"default" | "full-hd") | ||
xrandr --output $output --mode 1920x1080;; | ||
"native") | ||
xrandr --output $output --auto;; | ||
*) | ||
echo "Unknown scaling preference '$scaling_pref'. Applying auto."; | ||
xrandr --output $output --auto;; | ||
esac | ||
done | ||
fi |