mirror of
https://github.com/Mastermindzh/dotfiles.git
synced 2025-01-20 18:41:50 +01:00
75 lines
2.0 KiB
Bash
75 lines
2.0 KiB
Bash
#!/bin/bash
|
|
|
|
# Define the layouts
|
|
layouts=("undocked" "docked")
|
|
|
|
# Define the settings for each layout
|
|
declare -A undocked_settings=(
|
|
["Xft.antialias"]="true"
|
|
["Xft.hinting"]="true"
|
|
["Xft.rgba"]="rgba"
|
|
["Xft.hintstyle"]="hintslight"
|
|
["Xcursor.size"]="20"
|
|
["Xft.dpi"]="150"
|
|
["rofi.dpi"]="150"
|
|
)
|
|
|
|
declare -A docked_settings=(
|
|
["Xft.antialias"]="true"
|
|
["Xft.hinting"]="true"
|
|
["Xft.rgba"]="rgba"
|
|
["Xft.hintstyle"]="hintslight"
|
|
["Xcursor.size"]="20"
|
|
["Xft.dpi"]="120"
|
|
["rofi.dpi"]="120"
|
|
)
|
|
|
|
function updateXSettings() {
|
|
local dpi=$1
|
|
local dpi_value=$((dpi * 1024))
|
|
sed -i -E "/Xft\/DPI/s/[0-9]+/$dpi_value/" ~/.xsettingsd
|
|
killall -HUP xsettingsd
|
|
}
|
|
|
|
function applyLayout() {
|
|
local layout=$1
|
|
case $layout in
|
|
"undocked")
|
|
xrandr --output eDP --primary --mode 2880x1920 --pos 0x0 --rotate normal --output DisplayPort-0 --off --output DisplayPort-1 --off --output DisplayPort-2 --off --output DisplayPort-3 --off --output DisplayPort-4 --off --output DisplayPort-5 --off --output DisplayPort-6 --off --output DisplayPort-7 --off
|
|
updateXResources undocked_settings
|
|
updateXSettings 150
|
|
;;
|
|
"docked")
|
|
xrandr --output eDP --off --output DisplayPort-0 --off --output DisplayPort-1 --off --output DisplayPort-2 --off --output DisplayPort-3 --primary --mode 2560x1440 --pos 0x0 --rotate normal --output DisplayPort-4 --off --output DisplayPort-5 --off --output DisplayPort-6 --off --output DisplayPort-7 --off
|
|
updateXResources docked_settings
|
|
updateXSettings 120
|
|
;;
|
|
*)
|
|
echo "Unknown layout: $layout"
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
function updateXResources() {
|
|
local -n settings=$1
|
|
true >~/.Xresources
|
|
for key in "${!settings[@]}"; do
|
|
echo "$key: ${settings[$key]}" >>~/.Xresources
|
|
done
|
|
xrdb -merge ~/.Xresources
|
|
}
|
|
|
|
layout=$1
|
|
if [ -z "$layout" ]; then
|
|
layout=$(zenity --list --title="Select Monitor Layout" --column="Layout" "${layouts[@]}")
|
|
fi
|
|
|
|
if [ -n "$layout" ]; then
|
|
applyLayout "$layout"
|
|
i3-msg restart
|
|
else
|
|
echo "No layout selected."
|
|
exit 1
|
|
fi
|