sway/.config/sway/kdpi/genbg.bash

31 lines
807 B
Bash
Executable File

#!/usr/bin/bash -x
# Check that SWAYSOCK is in the env before doing anything
if [[ ! -v SWAYSOCK ]]; then
echo '$SWAYSOCK Not set in env. Exiting.'
exit 0
fi
# Path to genbg.gp
genbg="/home/thurstylark/.config/sway/$(uname -n)/genbg.gp"
# Scale mode and fallback color (See: man sway-output)
scalemode="center"
color='#0000FF'
# Retrieve dimensions of currently connected display
outw=$(swaymsg -r -t get_outputs | jq -r '.[0].current_mode.width')
outh=$(swaymsg -r -t get_outputs | jq -r '.[0].current_mode.height')
# Set up a tempfile for the background location
bgstash="$(mktemp tl-sway-bg.XXXX)"
# Clean up any old files
rm ${bgstash%.*}.*
# Generate the file in question
gnuplot -c "$genbg" "$outw" "$outh" > "$bgstash"
# Set the background
swaymsg "output * bg $bgstash $scalemode $color"