Files
dotfiles/i3/auto_monitor.sh

23 lines
597 B
Bash
Raw Normal View History

#! /bin/sh
#
# monitors.sh
# Copyright (C) 2017 Fabian Ising <fabian@murgi.de>
#
# Distributed under terms of the Apache v2.0 license.
#
# Get out of town if something errors
set -e
HDMI_STATUS=$(</sys/class/drm/card0/card0-HDMI-A-1/status )
if [ "connected" == "$HDMI_STATUS" ]; then
/usr/bin/xrandr --output eDP-1 --auto --left-of HDMI-1
/usr/bin/notify-send --urgency=low -t 5000 "Graphics Update" "HDMI plugged in"
else
/usr/bin/xrandr --output HDMI-1 --off
/usr/bin/notify-send --urgency=low -t 5000 "Graphics Update" "External monitor disconnected"
exit
fi