xps-dots/.config/Scripts/i3-resurrect-save-all

28 lines
831 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# i3-resurrect-save-all
# this program saves all currently active workspaces with i3-resurrect -
# arguments: take no arguments and assumes .i3/i3-resurrect is at "~/"
# expected output: showin what workspace is currently being saved and sends a notification when done
# example suggested usage: i3-resurrect-save-all
# remove old saves
rm -f ~/.config/i3-resurrect/*
# find running workspaces
workspaces=$(i3-msg -t get_workspaces | jq '.[] | .name')
echo "Found workspaces: $workspaces"
# Save workspaces with programs running
for ws in ${workspaces[*]}; do
# remove quotes from output
temp="${ws%\"}"
temp="${temp#\"}"
echo "saving $temp"
i3-resurrect save -w $temp -d ~/.config/i3/i3-resurrect
done
notify-send "i3-resurrect" "Saved all workspaces"