Skip to content

Commit

Permalink
Convert gen-screenshots from fish to bash
Browse files Browse the repository at this point in the history
  • Loading branch information
bim9262 committed Jan 3, 2025
1 parent 4dd8ae4 commit 5ddbdde
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
24 changes: 0 additions & 24 deletions gen-screenshots/gen-screenshots.fish

This file was deleted.

43 changes: 43 additions & 0 deletions gen-screenshots/gen-screenshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

cd "$(dirname "$0")"

SOCK_FILE=sway_i3rs.sock

set_theme() {
theme_name=$1
sed -i -r "s/theme = .*/theme = \"$theme_name\"/" screenshot_config.toml
}

cleanup() {
# Reset theme so that config is not changed
set_theme srcery
# Remove the socket file
rm -f $SOCK_FILE
}

trap cleanup EXIT

# Screenshot area depends on the current monitor's position and size, and we only want the relevant part of the bar
read x y w <<< $(swaymsg -t get_outputs | jq --raw-output ".. | objects | select(.focused == true) | .rect | \"\(.x) \(.y) \(.width)\"")
BAR_COORDS="$(($w/2 + $x)),$y $(($w/2))x16"


SWAYSOCK=$SOCK_FILE I3RS_PWD=$PWD sway --config swayconfig_i3rs &
sleep 1
swaymsg fullscreen toggle

for theme in ../files/themes/*; do
theme_name=$(basename $theme .toml)
if [ -f ../img/themes/"$theme_name".png ]; then
echo Image for theme $theme_name already exists, skipping
continue
fi
set_theme $theme_name
pkill -SIGUSR2 i3status-rs
sleep 1
grim -g "$BAR_COORDS" ../img/themes/"$theme_name".png
done

SWAYSOCK=$SOCK_FILE swaymsg exit

0 comments on commit 5ddbdde

Please sign in to comment.