Skip to content

Commit

Permalink
🔧 set-display: simplify asus profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianmiranda committed Nov 13, 2024
1 parent d9df0dd commit e1623e4
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 113 deletions.
14 changes: 4 additions & 10 deletions home/.config/sxhkd/sxhkdrc
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,13 @@ super + shift + t; r

# Set Display
super + shift + d; 1
~/bin/set-display single
~/bin/set-display asus_single
super + shift + d; 2
~/bin/set-display dual
~/bin/set-display asus_double
super + shift + d; 3
~/bin/set-display three-monitors
~/bin/set-display asus_triple
super + shift + d; 4
~/bin/set-display four-monitors
super + shift + d; a
~/bin/set-display single-inverted
super + shift + d; f
~/bin/set-display dual-inverted
super + shift + d; h
~/bin/set-display hdmi
~/bin/set-display asus_quadruple
super + shift + d; l
~/bin/set-display laptop
super + shift + d; v
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
xrandr --output DisplayPort-0 --primary --mode 2560x1440 --pos 2560x0 --rotate normal --output DisplayPort-1 --off --output DisplayPort-2 --off --output HDMI-A-0 --mode 2560x1440 --pos 0x0 --rotate normal
xrandr --output DisplayPort-0 --primary --mode 2560x1440 --pos 2560x0 --rotate normal --output DisplayPort-1 --off --output DisplayPort-2 --mode 2560x1440 --pos 0x0 --rotate normal --output HDMI-A-0 --off
5 changes: 0 additions & 5 deletions home/.screenlayout/asus_dual_inverted.sh

This file was deleted.

5 changes: 0 additions & 5 deletions home/.screenlayout/asus_hdmi.sh

This file was deleted.

File renamed without changes.
2 changes: 0 additions & 2 deletions home/.screenlayout/asus_single_inverted.sh

This file was deleted.

File renamed without changes.
130 changes: 40 additions & 90 deletions home/bin/set-display
Original file line number Diff line number Diff line change
@@ -1,133 +1,83 @@
#!/bin/bash

PROFILE_LAPTOP="laptop";
PROFILE_SINGLE="single";
PROFILE_SINGLE_INVERTED="single-inverted";
PROFILE_DUAL="dual";
PROFILE_DUAL_INVERTED="dual-inverted";
PROFILE_VIRTUAL="virtual";
PROFILE_HDMI="hdmi"
PROFILE_THREE_MONITORS="three-monitors"
PROFILE_FOUR_MONITORS="four-monitors"
# Define display profiles
PROFILE_LAPTOP="laptop"
PROFILE_VIRTUAL="virtual"

# ASUS display profiles
PROFILE_ONE_MONITOR="asus_single"
PROFILE_TWO_MONITORS="asus_double"
PROFILE_THREE_MONITORS="asus_triple"
PROFILE_FOUR_MONITORS="asus_quadruple"

XRANDR_DISPLAY_PROFILE=$1

# Kill polybar
killall -q polybar

echo "Applying display profile: $XRANDR_DISPLAY_PROFILE"

# Reload Xresources
xrdb ~/.Xresources

# Set default cursor size
CURSOR_SIZE=8

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_LAPTOP" ]]; then
xrdb -merge ~/.Xresources.laptop

CURSOR_SIZE=48

# Xresources.DPI * 1024
echo "Xft/DPI 196608" > ~/.xsettingsd

bash ~/.screenlayout/laptop.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_SINGLE" ]]; then
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/asus_single.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_SINGLE_INVERTED" ]]; then
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/asus_single_inverted.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_DUAL" ]]; then
else
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/asus_dual.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_DUAL_INVERTED" ]]; then
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/asus_dual_inverted.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_VIRTUAL" ]]; then
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/virtual.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_HDMI" ]]; then
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/asus_hdmi.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_THREE_MONITORS" ]]; then
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/three_asus.sh
fi

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_FOUR_MONITORS" ]]; then
xrdb -merge ~/.Xresources.asus

# Xresources.DPI * 1024
echo "Xft/DPI 98304" > ~/.xsettingsd

bash ~/.screenlayout/four_asus.sh
case "$XRANDR_DISPLAY_PROFILE" in
"$PROFILE_VIRTUAL")
bash ~/.screenlayout/virtual.sh
;;
"$PROFILE_ONE_MONITOR")
bash ~/.screenlayout/asus_single.sh
;;
"$PROFILE_TWO_MONITORS")
bash ~/.screenlayout/asus_double.sh
;;
"$PROFILE_THREE_MONITORS")
bash ~/.screenlayout/asus_triple.sh
;;
"$PROFILE_FOUR_MONITORS")
bash ~/.screenlayout/asus_quadruple.sh
;;
*)
echo "Unknown display profile: $XRANDR_DISPLAY_PROFILE"
exit 1
;;
esac
fi

# Get screen resolution
SCREEN_RESOLUTION=$(~/bin/get-resolution)
echo $SCREEN_RESOLUTION > /tmp/screen-resolution

# killall -HUP xsettingsd # Kill xsettingsd to be restarted by the WM. Used to scale GTK apps when going 2K <=> 4K
# Restart xsettingsd
systemctl --user restart xsettingsd.service

# Set cursor size
xsetroot -xcf /usr/share/icons/breeze_cursors/cursors/left_ptr $CURSOR_SIZE

#
# Prevents color scheme changes after switching between PC and console
#
# Prevent color scheme changes after switching between PC and console
xrandr --output HDMI-A-0 --set "Colorspace" "Default"
xrandr --output HDMI-A-0 --set "content type" "No Data"

if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_DUAL" || "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_DUAL_INVERTED" ]]; then
# Move workspaces for dual monitor setups
if [[ "$XRANDR_DISPLAY_PROFILE" == "$PROFILE_TWO_MONITORS" ]]; then
for i in 1 2 3 4 10; do
i3-msg "workspace $i, move workspace to output HDMI-A-0"
i3-msg "workspace $i, move workspace to output DisplayPort-2"
done

for i in 5 6 7 8 9; do
i3-msg "workspace $i, move workspace to output DisplayPort-0"
done
fi

# Restart the window manager
$HOME/bin/wm -r

0 comments on commit e1623e4

Please sign in to comment.