Disable icons + replace usage of title by address for the filename + replace sed operation by json operations

This commit is contained in:
Hydroxycarbamide 2023-08-16 18:11:59 +02:00
parent f0723c9b55
commit 60711d8951
3 changed files with 49 additions and 58 deletions

View file

@ -1,24 +1,14 @@
#! /bin/bash
hyprmsn=$HOME/.config/hyprmsn
mkdir $hyprmsn/windows 2> /dev/null
window=$(hyprctl activewindow -j | jq --raw-output .title)
rm -rf $hyprmsn/windows/*.jpeg 2> /dev/null
mkdir "$hyprmsn"/windows 2> /dev/null
rm -rf "$hyprmsn"/windows/*.jpeg 2> /dev/null
while true; do
new_window=$(hyprctl activewindow -j | jq --raw-output .title)
if [[ "$window" == "$new_window" ]]; then
continue
fi
window=$new_window
window_str=$(echo $window | sed -e 's/[]\/$*.^[]/\\&/g') #| sed 's/\[\([^]]*\)\]/\\[\1\\]/g') #add \ to []
window_no_slash=$(echo $window | sed 's|/||g')
at_size=$(hyprctl clients | sed -n "/$window_str/,/^\$/p" | grep -Ew 'at|size' | tr -d '[a-z]|:|\t| ')
at=$(echo $at_size | tr ' ' '\n' | head -1 | tail -1)
size=$(echo $at_size | tr ' ' '\n' | head -2 | tail -1 | tr ',' 'x')
window=$(hyprctl activewindow -j | jq -r)
address=$(echo "$window" | jq -r '.address')
at=$(echo "$window" | jq -r '.at' | jq -r 'join(",")')
size=$(echo "$window" | jq -r '.size' | jq -r 'join("x")')
grim -g "$at $size" -t jpeg -q 50 "$hyprmsn/windows/$address.jpeg"
sleep 0.4
grim -g "$at $size" -t jpeg -q 50 "$hyprmsn/windows/$window_no_slash.jpeg"
done