-
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.
Merge pull request #199 from yfyf/hdmi-hotplug
Display monitor hotplugging v2
- Loading branch information
Showing
6 changed files
with
474 additions
and
26 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,48 @@ | ||
set -euo pipefail | ||
|
||
SCALING_PREF=$(cat /var/lib/gui-localization/screen-scaling 2>/dev/null || echo "default") | ||
readonly SCALING_PREF | ||
|
||
CONNECTED_OUTPUTS=$(xrandr | grep ' connected' | awk '{ print $1 }') | ||
readonly CONNECTED_OUTPUTS | ||
|
||
echo -e "Connected outputs:\n$CONNECTED_OUTPUTS\n" | ||
|
||
scaling_pref_params="" | ||
|
||
echo "Using scaling preference '$SCALING_PREF'" | ||
|
||
case "$SCALING_PREF" in | ||
"default" | "full-hd") | ||
scaling_pref_params=(--mode 1920x1080) | ||
;; | ||
"native") | ||
scaling_pref_params=(--auto) | ||
;; | ||
*) | ||
scaling_pref_params=(--auto) | ||
;; | ||
esac | ||
|
||
if [ -z "$CONNECTED_OUTPUTS" ]; then | ||
|
||
echo "Error: no connected outputs found. Not applying any changes." | ||
|
||
else | ||
|
||
first_functional_output="" | ||
for output in $CONNECTED_OUTPUTS; do | ||
if [ -z "$first_functional_output" ]; then | ||
if xrandr --output "$output" --primary "${scaling_pref_params[@]}"; then | ||
first_functional_output=$output | ||
echo "Configured display $output as primary" | ||
else | ||
echo "Failed to configure display $output" | ||
fi | ||
else | ||
xrandr --output "$output" \ | ||
--same-as "$first_functional_output" \ | ||
"${scaling_pref_params[@]}" || echo "Failed to configure display $output" | ||
fi | ||
done | ||
fi |
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
Oops, something went wrong.