Skip to content

Instantly share code, notes, and snippets.

@mxdevmanuel
Created August 7, 2019 17:21
Show Gist options
  • Save mxdevmanuel/17f52326a7089164f08c08530005d591 to your computer and use it in GitHub Desktop.
Save mxdevmanuel/17f52326a7089164f08c08530005d591 to your computer and use it in GitHub Desktop.
i3 hdmi detect
#!/bin/bash
export DISPLAY=:0
export XAUTHORITY=/home/manuel/.Xauthority
export XDG_RUNTIME_DIR=/run/user/$(id -u)
hdmi_active="$(cat /sys/class/drm/card0/*HDMI*/status | grep '^connected')"
echo $hdmi_active
if [[ "$hdmi_active" == "connected" ]]; then
notify-send -i "/usr/share/icons/Paper/16x16/devices/computer.png" -t 3000 "HDMI: connected"
exec /home/manuel/.screenlayout/i3.sh &
else
notify-send -i "/usr/share/icons/Paper/16x16/devices/computer.png" -t 3000 "HDMI: disconnected"
exec /home/manuel/.screenlayout/single.sh &
fi
#!/bin/sh
xrandr --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output LVDS1 --primary --mode 1366x768 --pos 1920x312 --rotate normal --output VIRTUAL1 --off --output DP1 --off --output VGA1 --off
#!/bin/sh
xrandr --output HDMI1 --off --output LVDS1 --primary --mode 1366x768 --pos 0x0 --rotate normal --output VIRTUAL1 --off --output DP1 --off --output VGA1 --off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment