#!/bin/sh appid=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[],.floating_nodes[]) | select(.focused).app_id') printf "appid = %s\n" "$appid" >> /tmp/smart-foot-spawn.log dir="" case "$appid" in foot) cwd="$(swaymsg -t get_tree | jq -r 'recurse(.nodes[],.floating_nodes[])|select(.focused).name')" printf "cwd = %s\n" "$cwd" >> /tmp/smart-foot-spawn.log case "$cwd" in ""|*@*:*) dir=$HOME ;; *sfeed*|foot|pulsemixer) dir=/dev/shm ;; *) dir="$cwd" ;; esac ;; ncmpc) dir=/media/storage/sound ;; *) # appid = null when starting from empty desktop dir=$HOME ;; esac [ -d "$dir" ] || dir=$HOME exec foot -d none -D "$dir"