I've updated my "claude wants user input" script. It's now a bit more complicated, but it will now open the configured editor/IDE on the path where claude is running when you click on the notification so you don't have to search the agent's window.
Changes
- It's quite frustrating to come back to a coding agent after a while only to see that it needed user input only 10 seconds into the task.
-You can set up [notification hooks](https://code.claude.com/docs/en/hooks#notification) to trigger a Desktop notification (or similar) whenever the Claude Code agent halts. - +You can set up [notification hooks](https://code.claude.com/docs/en/hooks#notification) to trigger a Desktop notification (or similar) whenever the Claude Code agent halts. Clicking the notification will open your configured IDE in the correct project directory.
- 
- This is my configuration:
- ```sh
- # ~/.claude/notify.sh
- # Note: You need to `chmod +x` this
- #!/bin/bash
- +
- +# Test usage:
- +# echo '{ "title": "foo", "message": "bar" }' | bash ~/.claude/notify.sh
- +
- +EDITOR_COMMAND="/snap/bin/rubymine"
- +
- INPUT=$(cat)
- +INPUT=${INPUT:-"{}"}
- TITLE=$(echo "$INPUT" | jq -r '.title // "Claude Code"')
-MSG=$(echo "$INPUT" | jq -r '.message // "Needs your input"')- +MESSAGE=$(echo "$INPUT" | jq -r '.message // "Needs your input"')
- +ICON=$(echo "$INPUT" | jq -r '.icon // "dialog-question"')
- +
-notify-send "$TITLE" "$MSG" --icon=dialog-question- +# We use Python here because GNOME Shell's notification daemon does not emit
- +# D-Bus ActionInvoked signals for the "default" click action. Only libnotify
- +# with a GLib main loop can reliably handle click-to-open-editor on GNOME.
- +python3 - "$TITLE" "$MESSAGE" "$PWD" "$ICON" "$EDITOR_COMMAND" << 'PYTHON' > /dev/null 2>&1 & disown
- +import sys
- +import subprocess
- +import gi
- +
- +gi.require_version('Notify', '0.7')
- +from gi.repository import Notify, GLib
- +
- +title = sys.argv[1]
- +message = sys.argv[2]
- +working_directory = sys.argv[3]
- +icon = sys.argv[4]
- +editor_command = sys.argv[5]
- +
- +def on_notification_click(notification, action, user_data):
- + subprocess.Popen([editor_command, working_directory], start_new_session=True)
- + loop.quit()
- +
- +def on_close(notification):
- + loop.quit()
- +
- +Notify.init("Claude Code")
- +notification = Notify.Notification.new(title, message, icon)
- +notification.add_action("default", "Open Editor", on_notification_click, None)
- +notification.connect("closed", on_close)
- +notification.show()
- +
- +# Keep the script alive waiting for the user's click or dismissal
- +loop = GLib.MainLoop()
- +loop.run()
- +PYTHON
- ```
- ```sh
- # ~/.claude/settings.json
- {
- "hooks": {
- "Notification": [
- {
- "matcher": "permission_prompt|elicitation_dialog",
- "hooks": [
- {
- "type": "command",
- "command": "bash ~/.claude/notify.sh"
- }
- ]
- }
- ],
- "Stop": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "notify-send 'Claude Code' 'Finished its current task' --icon=dialog-information"- + "command": "echo '{\"title\": \"Claude Code\", \"message\": \"Finished its current task\", \"icon\": \"dialog-information\"}' | bash ~/.claude/notify.sh"
- }
- ]
- }
- ]
- },
- }
- ```
Posted by Michael Leimstädtner to makandra dev (2026-04-16 07:51)