feat(Justfile): cachix recipe and apply locally without ssh

This commit is contained in:
steveej 2023-05-23 18:09:54 +02:00
parent 349057f1c3
commit 5b6ecd0a25
8 changed files with 414 additions and 1 deletions

View file

@ -0,0 +1,41 @@
#!/usr/bin/env sh
# Get two outputs, visible workspaces and focused workspace
output1=$(swaymsg -t get_outputs --raw | jq '.[0].name' -r)
output2=$(swaymsg -t get_outputs --raw | jq '.[1].name' -r)
workspace1=$(swaymsg -t get_outputs --raw | jq '.[0].current_workspace' -r)
workspace2=$(swaymsg -t get_outputs --raw | jq '.[1].current_workspace' -r)
workspace_active=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true).name')
# If any of the outputs doesn't have a workspace, do nothing
if [ "$workspace1" = null ] || [ "$workspace2" = null ]; then
exit 0
else
# If script is provided with `follow` argument, then follow focused workspace
if [ "$1" = "follow" ]; then
if [ "$workspace1" = "$workspace_active" ]; then
swaymsg move workspace to output "$output2"
swaymsg workspace "$workspace2"
swaymsg move workspace to output "$output1"
swaymsg workspace "$workspace2"
else
swaymsg workspace "$workspace1"
swaymsg move workspace to output "$output2"
swaymsg workspace "$workspace2"
swaymsg move workspace to output "$output1"
fi
# Else focus stays with focused output
else
if [ "$workspace1" = "$workspace_active" ]; then
swaymsg move workspace to output "$output2"
swaymsg workspace "$workspace2"
swaymsg move workspace to output "$output1"
else
swaymsg workspace "$workspace1"
swaymsg move workspace to output "$output2"
swaymsg workspace "$workspace2"
swaymsg move workspace to output "$output1"
swaymsg workspace "$workspace1"
fi
fi
fi