Created
March 27, 2026 15:31
-
-
Save marcosnils/90ea98a9dfd2aa2a2887a7b6bcdc9d12 to your computer and use it in GitHub Desktop.
claude code sway alert focus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # 2. Find the container ID (con_id) associated with the FOOT_APP_ID env variable. | |
| # This variable gets injected while calling footclient from sway's config file. | |
| CONTAINER_ID=$(swaymsg -t get_tree | jq -r ".. | select(.app_id? == \"$FOOT_APP_ID\") | .id") | |
| if [ -z "$CONTAINER_ID" ]; then | |
| notify-send "Error" "Could not find container ID for PID $SCRIPT_PID" | |
| exit 1 | |
| fi | |
| # 3. Define the command to focus the window when the action is clicked | |
| # We use a wrapper script or function to ensure correct shell execution | |
| FOCUS_COMMAND="swaymsg [con_id=$CONTAINER_ID] focus" | |
| # 4. Use notify-send with the --action flag | |
| # The action value itself can be anything, the crucial part is handling the response. | |
| # The script will wait for the user to click the action, then execute the focus command. | |
| # Make sure the notification stays until action is taken (-t 0) | |
| # and print the output of notify-send (the action identifier "focus_window_action") | |
| ACTION_RESPONSE=$(notify-send --action="focus_window_action=Focus Window" \ | |
| "Claude code" \ | |
| "Claude Code requires attention" -t 0) | |
| # 5. Check if the specific action was triggered | |
| if [ "$ACTION_RESPONSE" = "focus_window_action" ]; then | |
| # Execute the command to focus the window via Sway IPC | |
| $FOCUS_COMMAND | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment