diff --git a/de/home/.config/eww/modules/bar.yuck b/de/home/.config/eww/modules/bar.yuck index 216b739..4538e83 100644 --- a/de/home/.config/eww/modules/bar.yuck +++ b/de/home/.config/eww/modules/bar.yuck @@ -18,20 +18,21 @@ (windowtitle) (scratchpad :array scratchpadArray))) -(defpoll scratchpadArray :interval "5s" - 'scripts/bar/scratchpad') -(defwidget scratchpad [array] - (box :orientation "v" - :space-evenly false - :class "workspaces" - (box :space-evenly false - (for entry in array - (button :tooltip "${entry.name} -test" - (image :path {entry.icon} - :image-width 25 - :image-height 25) - ))))) +;(deflisten scratchpadArray :initial "${[1]}" +; 'scripts/bar/scratchpad') +;(defwidget scratchpad [array] +; (box :orientation "v" +; :space-evenly false +; :class "workspaces" +; (box :space-evenly false +; (for entry in array +; (button :onclick 'swaymsg [con_id=${entry.win_id}] focus' +; :tooltip "${entry.name} +;${entry.title}" +; (image :path {entry.icon} +; :image-width 25 +; :image-height 25) +; ))))) ; (image :path "/usr/share/icons/hicolor/scalable/apps/org.kde.dolphin.svg" ; :image-width 25 ; :image-height 25) @@ -62,6 +63,7 @@ test" (include "modules/bar/profile.yuck") (include "modules/bar/workspaces.yuck") (include "modules/bar/window_name.yuck") +(include "modules/bar/scratchpad.yuck") ;centergroup (include "modules/bar/music.yuck") diff --git a/de/home/.config/eww/modules/bar/scratchpad.yuck b/de/home/.config/eww/modules/bar/scratchpad.yuck new file mode 100644 index 0000000..41df1cb --- /dev/null +++ b/de/home/.config/eww/modules/bar/scratchpad.yuck @@ -0,0 +1,15 @@ +(deflisten scratchpadArray :initial "${[1]}" + 'scripts/bar/scratchpad') +(defwidget scratchpad [array] + (box :orientation "h" + :space-evenly false + :class "workspaces" +; (box :space-evenly false + (for entry in array + (button :onclick 'swaymsg [con_id=${entry.win_id}] focus' + :tooltip "${entry.name} +${entry.title}" + (image :path {entry.icon} + :image-width 20 + :image-height 20) + )))) diff --git a/de/home/.config/eww/scripts/bar/scratchpad b/de/home/.config/eww/scripts/bar/scratchpad index d4d7f2e..54e4d2d 100755 --- a/de/home/.config/eww/scripts/bar/scratchpad +++ b/de/home/.config/eww/scripts/bar/scratchpad @@ -152,37 +152,27 @@ get_icon() { echo "$icon" } -id_fmt='%s' -ws_fmt='%s' -app_fmt='%-15.15s' -title_fmt='%s' - -applist_array=() -applist="" -shopt -s lastpipe -swaymsg -t get_tree | -# get list of windows as tab-separated columns -jq -r "$jq_get_windows | $jq_windows_to_tsv" | -column -s $'\t' -o $'\t' -t | while IFS=$'\t' read -r win_id ws_name app_name win_title pid; do +function get_scratchpad() { + applist_array=() + applist="" + shopt -s lastpipe + swaymsg -t get_tree | + # get list of windows as tab-separated columns + jq -r "$jq_get_windows | $jq_windows_to_tsv" | + column -s $'\t' -o $'\t' -t | while IFS=$'\t' read -r win_id ws_name app_name win_title pid; do shopt -s extglob app_name="${app_name%%*( )}" icon=$( get_icon "$app_name" "$pid" ) [[ "$verbose" ]] && printf "[%s]=%s\n" "$app_name" "$icon" >&2 # shellcheck disable=SC2059 - applist_array_item=$(jq -n --arg icon "${icon}" --arg name "${app_name##*.}" '{icon: $icon,name: $name}') + applist_array_item=$(jq -n --arg icon "${icon}" --arg name "${app_name##*.}" --arg title "${win_title}" --arg win_id "${win_id}" '{icon: $icon,name: $name,title: $title,win_id: $win_id}') # echo "${applist_array_item}" applist_array+=("${applist_array_item}") # echo "${applist_array[@]}" - applist=$(printf '%s\n' "${applist_array[@]}" | jq -s .) -# echo ${applist} -# jq -n --arg icon "${icon}" --arg name "${app_name##*.}" '{icon: $icon,name: $name}' -# printf "img:$icon:text:${id_fmt}\t${app_fmt}\t${ws_fmt}\t${title_fmt}\n" \ -# "$win_id" \ -# "${app_name##*.}" \ -# "$ws_name" \ -# "$win_title" -done -echo ${applist} + done + applist=$(printf '%s\n' "${applist_array[@]}" | jq -s .) + echo ${applist} +} #echo "${applist_array[@]}" #printf '%s\n' "${applist_array[@]}" #echo "${applist_array[@]}" @@ -190,3 +180,10 @@ echo ${applist} #echo ${applist} #sort -k3 -k2 #wofi --cache-file=/dev/null --insensitive --allow-images --show dmenu --prompt='Focus a window' + +get_scratchpad +swaymsg -t subscribe '["window"]' --monitor | { + while read -r event; do + get_scratchpad + done +}