diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..99ef49e --- /dev/null +++ b/config.ini @@ -0,0 +1,3 @@ +[daemon] +use_icons=false +icon_pack=Papirus \ No newline at end of file diff --git a/eww/hyprmsn/scripts/windows.sh b/eww/hyprmsn/scripts/windows.sh index dbd6263..4478c50 100755 --- a/eww/hyprmsn/scripts/windows.sh +++ b/eww/hyprmsn/scripts/windows.sh @@ -32,16 +32,35 @@ echo "(box" OLD_IFS="$IFS" 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 + +i=1 for window in $windows; do + window_class=$(echo $classes | tr ' ' '\n' | head -$i | tail -1) window_str=$(trun $window) window_img=$(img $window) + + if [ $use_icons == true ]; then + 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 + #echo $window_img - eww="(box :orientation \"v\" :class \"window-box\" (image :path \"$window_img\" :image-width 192 :image-height 108) (button :onclick \"scripts/move_to_window.sh \'$window\'\" :class \"window-button\" (box :orientation \"v\" " + 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\" " for string in $(echo -e $window_str); do eww="$eww $(echo -e "(label :text \"$string\")")" done eww="$eww)))" echo $eww + + i=$(( $i + 1 )) done IFS=$OLD_IFS echo ")" diff --git a/install.sh b/install.sh index 47ee5af..80563d7 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,28 @@ +#! /bin/bash + +# prerequisites +if ! command -v eww &> /dev/null +then + echo "eww could not be found" + echo "install eww-wayland to continue" + exit +fi + +if ! command -v grim &> /dev/null +then + echo "grim could not be found" + echo "install grim to continue" + exit +fi + + mkdir ~/.config/eww 2> /dev/null +echo "created eww dir if it didn't existed" cp -r eww/* ~/.config/eww +echo "copied the hyprmsn folder to the eww config" mkdir ~/.config/hyprmsn 2> /dev/null +echo "created the hyprmsn dir" cp -r scripts windows ~/.config/hyprmsn/ +echo "copied the scripts, windows to the hyprmsn dir" +cp config.ini ~/.config/hyprmsn/ +echo "copied the config.ini to the hyprmsn dir" \ No newline at end of file diff --git a/scripts/clients.sh b/scripts/clients.sh index df3a71e..71b1249 100755 --- a/scripts/clients.sh +++ b/scripts/clients.sh @@ -1,5 +1,5 @@ #! /bin/bash -missioncontroldir=$HOME/.config/hyprmsn +hyprmsn=$HOME/.config/hyprmsn OLDIFS="$IFS" IFS=$'\n' # bash specific @@ -8,8 +8,8 @@ do special_line=$line special_line=$(echo $special_line | sed 's/\[\([^]]*\)\]/\\[\1\\]/g') #add \ to [] special_line=$(echo $special_line | sed 's/'\''\.\*\\^//g') #add \ to special characters - icon=$(ls "$missioncontroldir/windows" | grep -F $special_line) - echo -en "$line\x00icon\x1f$missioncontroldir/windows/$icon\n" + icon=$(ls "$hyprmsn/windows" | grep -F $special_line) + echo -en "$line\x00icon\x1f$hyprmsn/windows/$icon\n" done | rofi -dmenu ) IFS="$OLDIFS" diff --git a/scripts/daemon.sh b/scripts/daemon.sh index 9555870..6039f09 100755 --- a/scripts/daemon.sh +++ b/scripts/daemon.sh @@ -1,9 +1,9 @@ #! /bin/bash -missioncontroldir=$HOME/.config/hyprmsn -mkdir $missioncontroldir/windows 2> /dev/null +hyprmsn=$HOME/.config/hyprmsn +mkdir $hyprmsn/windows 2> /dev/null window=$(hyprctl activewindow -j | jq --raw-output .title) -rm -rf $missioncontroldir/windows/*.jpeg 2> /dev/null +rm -rf $hyprmsn/windows/*.jpeg 2> /dev/null while true; do new_window=$(hyprctl activewindow -j | jq --raw-output .title) @@ -20,5 +20,5 @@ while true; do 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 - grim -g "$at $size" -t jpeg -q 50 "$missioncontroldir/windows/$window_no_slash.jpeg" + grim -g "$at $size" -t jpeg -q 50 "$hyprmsn/windows/$window_no_slash.jpeg" done diff --git a/scripts/load_config.sh b/scripts/load_config.sh new file mode 100755 index 0000000..b63b21a --- /dev/null +++ b/scripts/load_config.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +config=$HOME/.config/hyprmsn/config.ini + +section() { + section_name=$1 + + sed -n "/\[$section_name\]/,/^$/p" $config | sed -E "s/\[.*\]//g" | sed '/^[[:space:]]*$/d' +} + +# daemon section +section daemon > /dev/null + +# SOURCING +# support comments +sed "s/;/#/g" $config | grep -Ev "\[.*\]" | source /dev/stdin + +# remove spaces +source <(grep = $config | sed 's/ *= */=/g') \ No newline at end of file