New backup 2025-03-11 22:00:02
This commit is contained in:
parent
7399625f4f
commit
5dd6372c7c
1 changed files with 1 additions and 17 deletions
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
#appropriated from https://gitlab.com/wef/dotfiles/-/blob/master/bin/sway-select-window for use with eww
|
||||
|
||||
declare -A icons=(
|
||||
)
|
||||
|
@ -92,17 +93,14 @@ get_icon() {
|
|||
[[ "$verbose" ]] && echo "using hardcoded icon '$icon'" >&2
|
||||
return
|
||||
}
|
||||
|
||||
# let's go poke in the .desktop files:
|
||||
icon_name=""
|
||||
dt=$( get_desktop "$app" )
|
||||
|
||||
# sometimes we get the 'class' rather than the exe - so try this:
|
||||
[[ "$dt" ]] || {
|
||||
app=$( tr '\0' '\n' < "/proc/$pid/cmdline" | head -n 1 )
|
||||
dt=$( get_desktop "$( basename "$app" )" )
|
||||
}
|
||||
|
||||
[[ "$dt" ]] && {
|
||||
icon_name=$( awk -v IGNORECASE="set" -F"=" '/^icon/ {print $2}' "$dt" )
|
||||
[[ -r "$icon_name" ]] && {
|
||||
|
@ -137,15 +135,12 @@ get_icon() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
# desperation street:
|
||||
icon=$( find /usr/share/icons /usr/share/pixmaps | grep -E -i "/$app.(png|svg)" | head -n 1 )
|
||||
[[ "$icon" && -r "$icon" ]] && {
|
||||
echo "$icon"
|
||||
[[ "$verbose" ]] && echo "using found icon '$icon'" >&2
|
||||
return
|
||||
}
|
||||
|
||||
# failed:
|
||||
icon="/usr/share/gtk-doc/html/gtk2/image-missing.png"
|
||||
[[ "$verbose" ]] && echo "using missing icon '$icon'" >&2
|
||||
|
@ -157,29 +152,18 @@ function get_scratchpad() {
|
|||
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##*.}" --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[@]}"
|
||||
done
|
||||
applist=$(printf '%s\n' "${applist_array[@]}" | jq -s .)
|
||||
echo ${applist}
|
||||
}
|
||||
#echo "${applist_array[@]}"
|
||||
#printf '%s\n' "${applist_array[@]}"
|
||||
#echo "${applist_array[@]}"
|
||||
#applist=$(printf '%s\n' "${applist_array[@]}" | jq -s .)
|
||||
#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 | {
|
||||
|
|
Loading…
Add table
Reference in a new issue