]> git.friedersdorff.com Git - max/saltfiles.git/blob - states/sway/files/monitor_switch_sway
Better notifications
[max/saltfiles.git] / states / sway / files / monitor_switch_sway
1 #!/bin/sh
2
3 {% if grains['host'] == 'baryte' %}
4 {% set ext = "DP-3" %}
5 {% else %}
6 {% set ext = "DP-1" %}
7 {% endif %}
8
9 FILE="/proc/acpi/button/lid/LID*/state"
10 last=-1
11 while true; do
12         grep -q open ${FILE}
13         current="$?"
14         if [ $last -ne $current ]; then
15                 if [ $current -eq 0 ]; then
16                         swaymsg output {{ ext }} disable
17                         swaymsg output eDP-1 enable
18                 else
19                         swaymsg output eDP-1 disable
20                         swaymsg output {{ ext }} enable
21                 fi
22         fi
23         last=$current
24         sleep 0.5
25 done