From 65c989ce4e5c9a40e85795bfe4c784ef189791a2 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Mon, 3 Oct 2022 16:57:31 +0100 Subject: [PATCH] Configure all the things --- states/setup-arch.sls | 2 ++ states/sway/arch.sls | 1 + states/sway/files/baryte | 2 ++ states/sway/files/config.jinja | 36 ++++++++++----------------- states/sway/files/monitor_switch_sway | 25 +++++++++++++++++++ states/sway/init.sls | 11 ++++++++ 6 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 states/sway/files/monitor_switch_sway diff --git a/states/setup-arch.sls b/states/setup-arch.sls index b2579ac..fda05dd 100644 --- a/states/setup-arch.sls +++ b/states/setup-arch.sls @@ -7,6 +7,8 @@ install pulseaudio: - pulseaudio - git - man-db + - vifm + - devtools archmirror: file.managed: diff --git a/states/sway/arch.sls b/states/sway/arch.sls index e3a00fd..44936af 100644 --- a/states/sway/arch.sls +++ b/states/sway/arch.sls @@ -9,6 +9,7 @@ install sway: - mako - libnotify - dmenu + - sov ensure dmenu-wl wrapper: file.managed: diff --git a/states/sway/files/baryte b/states/sway/files/baryte index c5bc4d5..e2f7bc0 100644 --- a/states/sway/files/baryte +++ b/states/sway/files/baryte @@ -76,3 +76,5 @@ workspace 1 output DP-3 workspace 3 output DP-3 exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway +exec mako& +exec ~/.local/bin/monitor_switch_sway& diff --git a/states/sway/files/config.jinja b/states/sway/files/config.jinja index ac0da0f..30724ae 100644 --- a/states/sway/files/config.jinja +++ b/states/sway/files/config.jinja @@ -183,29 +183,17 @@ input 9610:4102:Gaming_KB__Gaming_KB { # Workspaces: # # Switch to workspace - bindsym $mod+1 workspace number 1 - bindsym $mod+2 workspace number 2 - bindsym $mod+3 workspace number 3 - bindsym $mod+4 workspace number 4 - bindsym $mod+5 workspace number 5 - bindsym $mod+6 workspace number 6 - bindsym $mod+7 workspace number 7 - bindsym $mod+8 workspace number 8 - bindsym $mod+9 workspace number 9 - bindsym $mod+0 workspace number 10 - # Move focused container to workspace - bindsym $mod+Shift+1 move container to workspace number 1 - bindsym $mod+Shift+2 move container to workspace number 2 - bindsym $mod+Shift+3 move container to workspace number 3 - bindsym $mod+Shift+4 move container to workspace number 4 - bindsym $mod+Shift+5 move container to workspace number 5 - bindsym $mod+Shift+6 move container to workspace number 6 - bindsym $mod+Shift+7 move container to workspace number 7 - bindsym $mod+Shift+8 move container to workspace number 8 - bindsym $mod+Shift+9 move container to workspace number 9 - bindsym $mod+Shift+0 move container to workspace number 10 - # Note: workspaces can have any name you want, not just numbers. - # We just use 1-10 as the default. + {% for i in range(10) %} + bindsym --no-repeat $mod+{{ i }} workspace number {{ i }}; exec "echo 1 > /tmp/sovpipe" + bindsym --release $mod+{{ i }} exec "echo 0 > /tmp/sovpipe" + + # Move focused container to workspace + bindsym $mod+Shift+{{ i }} move container to workspace number {{ i }} + {% endfor %} + + bindsym --no-repeat $mod+Shift exec "echo 1 > /tmp/sovpipe" + bindsym --release $mod+Shift exec "echo 0 > /tmp/sovpipe" + # # Layout stuff: # @@ -275,3 +263,5 @@ include /etc/sway/config.d/* # host specific section {%- do salt.log.error('sway/files/' + host) -%} {% include 'sway/files/' + host %} + +exec rm -f /tmp/sovpipe && mkfifo /tmp/sovpipe && tail -f /tmp/sovpipe | sov 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 diff --git a/states/sway/init.sls b/states/sway/init.sls index a134528..8d5c3e5 100644 --- a/states/sway/init.sls +++ b/states/sway/init.sls @@ -37,3 +37,14 @@ conky launch script: - user: {{ grains['user'] }} - group: {{ grains['user'] }} - mode: 750 + +{% if grains['host'] in ['baryte', 'barium', 'rhenium'] %} +monitor switch script: + file.managed: + - name: {{ grains['homedir'] }}/.local/bin/monitor_switch_sway + - source: salt://sway/files/monitor_switch_sway + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 750 + - template: jinja +{% endif %} -- 2.46.2