Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert gen-screenshots from fish to bash #2122

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"

swaymsg fullscreen off
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

Loading