This script allows you to get the current working directory of the focused window/view. If the window/view is running inside xwayland the script simply falls back to xcwd
, so that also needs to be installed.
This is useful if you want your terminal or other programs to open in the CWD of the curently focused window.
jq
xcwd
The script should work on both FreeBSD and Linux.
Add swaycwd
to your $PATH
and run the command like this:
$ swaycwd
/usr/home/qiu
Example sway config:
# Start a terminal in CWD
bindsym $mod+Shift+Return exec 'cd "$(swaycwd)" && st'