Skip to content

Instantly share code, notes, and snippets.

@lukateras
Last active February 12, 2023 22:34
Show Gist options
  • Save lukateras/492fdcd87f5d549a42a07db0a6a333e2 to your computer and use it in GitHub Desktop.
Save lukateras/492fdcd87f5d549a42a07db0a6a333e2 to your computer and use it in GitHub Desktop.
Print working directory of the focused Sway window
#!/usr/bin/env bash
set -euo pipefail
cpid=$(swaymsg --type=get_tree | jq '.. | select(.focused?).pid')
ppid=$(pgrep --newest --parent="$cpid")
readlink /proc/"$ppid"/cwd || echo "$HOME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment