X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=states%2Fsway%2Ffiles%2Fmonitor_switch_sway;fp=states%2Fsway%2Ffiles%2Fmonitor_switch_sway;h=6e198fc1894cc20327af790558cfcfebfb3ea46c;hb=65c989ce4e5c9a40e85795bfe4c784ef189791a2;hp=0000000000000000000000000000000000000000;hpb=52b50c2ba37d2c7d56929a728c27e684f823decd;p=max%2Fsaltfiles.git diff --git a/states/sway/files/monitor_switch_sway b/states/sway/files/monitor_switch_sway new file mode 100644 index 0000000..6e198fc --- /dev/null +++ b/states/sway/files/monitor_switch_sway @@ -0,0 +1,25 @@ +#!/bin/sh + +{% if grains['host'] == 'baryte' %} +{% set ext = "DP-3" %} +{% else %} +{% set ext = "DP-1" %} +{% endif %} + +FILE="/proc/acpi/button/lid/LID*/state" +last=-1 +while true; do + grep -q open ${FILE} + current="$?" + if [ $last -ne $current ]; then + if [ $current -eq 0 ]; then + swaymsg output {{ ext }} disable + swaymsg output eDP-1 enable + else + swaymsg output eDP-1 disable + swaymsg output {{ ext }} enable + fi + fi + last=$current + sleep 0.5 +done