Disable icons + replace usage of title by address for the filename + replace sed operation by json operations
This commit is contained in:
parent
f0723c9b55
commit
60711d8951
3 changed files with 49 additions and 58 deletions
|
@ -1,3 +1,5 @@
|
||||||
window_id=$(hyprctl clients | rg 'Window ([A-Fa-f0-9]+)' | grep -F "$*" | sed -E 's/Window (.*) \->.*/\1/g')
|
#!/bin/bash
|
||||||
hyprctl dispatch focuswindow address:0x$window_id > /dev/null
|
|
||||||
eww --config $HOME/.config/eww/hyprmsn close hyprmsn
|
window_id=$1
|
||||||
|
hyprctl dispatch focuswindow address:"$window_id" > /dev/null
|
||||||
|
eww --config "$HOME"/.config/eww/hyprmsn close hyprmsn
|
|
@ -1,66 +1,65 @@
|
||||||
#! /bin/bash
|
#!/bin/bash
|
||||||
|
word_per_line=3
|
||||||
trun() {
|
trun() {
|
||||||
window=$1
|
window=$1
|
||||||
OLD_IFS="$IFS"
|
OLD_IFS="$IFS"
|
||||||
IFS=$' '
|
IFS=$' '
|
||||||
for word in $window; do
|
for word in $window; do
|
||||||
if [[ $count == $word_per_line ]]; then
|
if [[ $count == "$word_per_line" ]]; then
|
||||||
str="$str$word\n"
|
str="$str$word\n"
|
||||||
count=0
|
count=0
|
||||||
else
|
else
|
||||||
str="$str$word "
|
str="$str$word "
|
||||||
count=$(($count + 1))
|
count=$((count + 1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
IFS=$OLD_IFS
|
||||||
echo $str
|
echo "$str"
|
||||||
}
|
}
|
||||||
|
|
||||||
img() {
|
|
||||||
window=$1
|
|
||||||
windows_images_dir=$HOME/.config/hyprmsn/windows
|
|
||||||
window_no_slash=$(echo $window | sed 's|/|⁄|g')
|
|
||||||
window_img="$windows_images_dir/$(ls $windows_images_dir | grep -F $window_no_slash | tail -1)"
|
|
||||||
if [[ $window_img == "$windows_images_dir/" ]]; then
|
|
||||||
window_img="$windows_images_dir/default.png"
|
|
||||||
fi
|
|
||||||
echo "$window_img"
|
|
||||||
}
|
|
||||||
|
|
||||||
word_per_line=3
|
|
||||||
echo "(box"
|
echo "(box"
|
||||||
OLD_IFS="$IFS"
|
OLD_IFS="$IFS"
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
windows=$(hyprctl clients | rg 'Window ([A-Fa-f0-9]+)' | sed -E 's/.*\-> (.*):/\1/g')
|
|
||||||
classes=$(hyprctl clients | rg 'class: ' | sed "s/.*class: //g")
|
|
||||||
|
|
||||||
source $HOME/.config/hyprmsn/scripts/load_config.sh
|
source $HOME/.config/hyprmsn/scripts/load_config.sh
|
||||||
|
|
||||||
i=1
|
current_workspace=$(hyprctl -j activeworkspace | jq -r '.id')
|
||||||
for window in $windows; do
|
windows_images_dir=$HOME/.config/hyprmsn/windows
|
||||||
window_class=$(echo $classes | tr ' ' '\n' | head -$i | tail -1)
|
hyprctl -j clients | jq -c '.[]' | while read -r window; do
|
||||||
window_str=$(trun $window)
|
workspace=$(echo "$window" | jq -r '.workspace.id')
|
||||||
window_img=$(img $window)
|
|
||||||
|
if [ "$workspace" -lt 0 ]; then
|
||||||
if [ $use_icons == true ]; then
|
continue
|
||||||
find_icon=$(find /usr/share/icons/$icon_pack -iname "$window_class*" | head -4 | tail -1)
|
|
||||||
if [[ $find_icon == "/usr/share/icons/$icon_pack" ]]; then
|
|
||||||
window_img=$(img $window)
|
|
||||||
fi
|
|
||||||
window_img=$find_icon
|
|
||||||
else
|
|
||||||
window_img=$(img $window)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#echo $window_img
|
address=$(echo "$window" | jq -r '.address')
|
||||||
eww="(box :orientation \"v\" :class \"window-box\" (image :path \"$window_img\" :image-width 192 :image-height 108) (button :onclick \"$HOME/.config/eww/hyprmsn/scripts/move_to_window.sh \'$window\'\" :class \"window-button\" (box :orientation \"v\" "
|
window_img="$windows_images_dir/$address.jpeg"
|
||||||
for string in $(echo -e $window_str); do
|
if [ "$workspace" -eq "$current_workspace" ]; then
|
||||||
|
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 "$window_img"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Implement icons
|
||||||
|
# find_icon=$(find /usr/share/icons/$icon_pack -iname "$window_class*" | head -4 | tail -1)
|
||||||
|
# if [[ $find_icon == "/usr/share/icons/$icon_pack" ]]; then
|
||||||
|
# window_img=$(img $window)
|
||||||
|
# fi
|
||||||
|
# window_img=$find_icon
|
||||||
|
|
||||||
|
if [ ! -e "$window_img" ]; then
|
||||||
|
window_img="$windows_images_dir/default.png"
|
||||||
|
fi
|
||||||
|
|
||||||
|
window_str=$(echo "$window" | jq -r '.title')
|
||||||
|
eww="(box :orientation \"v\" :class \"window-box\" (image :path \"$window_img\" :image-width 192 :image-height 108) (button :onclick \"$HOME/.config/eww/hyprmsn/scripts/move_to_window.sh \'$address\'\" :class \"window-button\" (box :orientation \"v\" "
|
||||||
|
for string in $(echo -e "$window_str"); do
|
||||||
eww="$eww $(echo -e "(label :text \"$string\")")"
|
eww="$eww $(echo -e "(label :text \"$string\")")"
|
||||||
done
|
done
|
||||||
eww="$eww)))"
|
eww="$eww)))"
|
||||||
echo $eww
|
echo "$eww"
|
||||||
|
|
||||||
i=$(( $i + 1 ))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
IFS=$OLD_IFS
|
IFS=$OLD_IFS
|
||||||
echo ")"
|
echo ")"
|
||||||
|
|
|
@ -1,24 +1,14 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
hyprmsn=$HOME/.config/hyprmsn
|
hyprmsn=$HOME/.config/hyprmsn
|
||||||
mkdir $hyprmsn/windows 2> /dev/null
|
mkdir "$hyprmsn"/windows 2> /dev/null
|
||||||
window=$(hyprctl activewindow -j | jq --raw-output .title)
|
rm -rf "$hyprmsn"/windows/*.jpeg 2> /dev/null
|
||||||
rm -rf $hyprmsn/windows/*.jpeg 2> /dev/null
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
new_window=$(hyprctl activewindow -j | jq --raw-output .title)
|
window=$(hyprctl activewindow -j | jq -r)
|
||||||
|
address=$(echo "$window" | jq -r '.address')
|
||||||
if [[ "$window" == "$new_window" ]]; then
|
at=$(echo "$window" | jq -r '.at' | jq -r 'join(",")')
|
||||||
continue
|
size=$(echo "$window" | jq -r '.size' | jq -r 'join("x")')
|
||||||
fi
|
grim -g "$at $size" -t jpeg -q 50 "$hyprmsn/windows/$address.jpeg"
|
||||||
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')
|
|
||||||
sleep 0.4
|
sleep 0.4
|
||||||
grim -g "$at $size" -t jpeg -q 50 "$hyprmsn/windows/$window_no_slash.jpeg"
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue