From 8d2f51b64ab8f2484df4b502f42b6990f45ac9fa Mon Sep 17 00:00:00 2001 From: Rick van Lieshout Date: Mon, 13 Jan 2025 22:49:28 +0100 Subject: [PATCH] added layout switcher for archfw --- computers/archfw/.Xresources | 11 +++-- computers/archfw/.bashrc | 4 ++ computers/archfw/displaySwitch.sh | 74 +++++++++++++++++++++++++++++++ computers/archfw/install.sh | 4 +- config/xfce4/thunar.xml | 4 +- 5 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 computers/archfw/.bashrc create mode 100644 computers/archfw/displaySwitch.sh diff --git a/computers/archfw/.Xresources b/computers/archfw/.Xresources index dfa6681..0b8f0c1 100644 --- a/computers/archfw/.Xresources +++ b/computers/archfw/.Xresources @@ -1,8 +1,7 @@ -Xft.antialias: true Xft.hinting: true -Xft.rgba: rgba -Xft.hintstyle: hintslight -Xcursor.size: 20 - -Xft.dpi: 150 rofi.dpi: 150 +Xcursor.size: 20 +Xft.hintstyle: hintslight +Xft.rgba: rgba +Xft.antialias: true +Xft.dpi: 150 diff --git a/computers/archfw/.bashrc b/computers/archfw/.bashrc new file mode 100644 index 0000000..e7a97be --- /dev/null +++ b/computers/archfw/.bashrc @@ -0,0 +1,4 @@ +#!/bin/bash +alias dock='bash ~/dotfiles/computers/archfw/displaySwitch.sh docked' +alias undock='bash ~/dotfiles/computers/archfw/displaySwitch.sh undocked' +alias displaySwitch='bash ~/dotfiles/computers/archfw/displaySwitch.sh' diff --git a/computers/archfw/displaySwitch.sh b/computers/archfw/displaySwitch.sh new file mode 100644 index 0000000..67f5934 --- /dev/null +++ b/computers/archfw/displaySwitch.sh @@ -0,0 +1,74 @@ +#!/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 diff --git a/computers/archfw/install.sh b/computers/archfw/install.sh index ed3b689..9b5facd 100644 --- a/computers/archfw/install.sh +++ b/computers/archfw/install.sh @@ -1,3 +1,5 @@ #!/bin/bash MY_PATH=$PWD/computers/archfw -ln -sf "$MY_PATH/.Xresources" ~/.Xresources + +# custom (laptop specific) bashrc thingies :) +ln -sf "$MY_PATH/.bashrc" ~/.custom diff --git a/config/xfce4/thunar.xml b/config/xfce4/thunar.xml index 4d50677..54a579b 100644 --- a/config/xfce4/thunar.xml +++ b/config/xfce4/thunar.xml @@ -4,8 +4,8 @@ - - + +