1
0
Fork 0
dotfiles/.local/bin/scripts/xr
2025-11-11 00:41:42 +03:00

40 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
change_dpi() {
sed -i -E --follow-symlinks "s/Xft\.dpi: .*?/Xft\.dpi: $1/g" ~/.Xresources
sed -i -E --follow-symlinks "s/Xcursor\.size: .*?/Xcursor\.size: $2/g" ~/.Xresources
sed -i -E --follow-symlinks "s/gtk-cursor-theme-size=.*?/gtk-cursor-theme-size=$2/g" ~/.config/gtk-3.0/settings.ini
sed -i -E --follow-symlinks "s/gtk-cursor-theme-size=.*?/gtk-cursor-theme-size=$2/g" ~/.gtkrc-2.0
echo "Xft/DPI $(($1 * 1024))" > ~/.xsettingsd
echo "Gtk/CursorThemeSize $2" >> ~/.xsettingsd
xrdb -merge ~/.Xresources
killall -HUP dwm
killall -HUP xsettingsd
}
EXT_MON="$(xrandr | grep -ow "\(DP-[0-9]\) connected" | cut -d " " -f 1)"
INT_MODELINE=$(cvt 1560 1040 90 | grep "Modeline" | cut -d " " -f 2- | tr -d '"')
INT_RES="$(echo $INT_MODELINE | cut -d ' ' -f 1 | tr -d '\"')"
if [[ -z "${EXT_MON}" ]] || [ "$1" = "internal" ]; then
xrandr --output eDP-1 --pos 0x0 --mode "3120x2080" --rate 90 --primary --output DP-1 --off --output DP-2 --off --output DP-3 --off --output DP-4 --off
xrandr --delmode eDP-1 "${INT_RES}"
xrandr --rmmode "${INT_RES}"
change_dpi 192 48
else
:
xrandr --rmmode "${INT_RES}"
# shellcheck disable=all
# temp remove edp
# xrandr --newmode $(echo $INT_MODELINE) # this is a hack to make xrandr recognize the resolution
# xrandr --addmode eDP-1 "${INT_RES}"
# xrandr --output eDP-1 --pos 2560x400 --mode "${INT_RES}" --output "${EXT_MON}" --pos 0x0 --mode "2560x1440" --rate 144 --primary
xrandr --output eDP-1 --off --output "${EXT_MON}" --pos 0x0 --mode "2560x1440" --rate 144 --primary
change_dpi 96 24
fi
exec "${HOME}/.config/X11/autostart"