Last active
February 25, 2026 07:01
-
-
Save scarf005/e05946fd2dced4b9bc54a66dae87486a to your computer and use it in GitHub Desktop.
me: mom can i have openclaw? mom: we have openclaw at home openclaw at home:
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
| #!/usr/bin/env fish | |
| if test (count $argv) -eq 0 | |
| echo "Usage: notify.fish \"Title\" \"Description\"" | |
| echo " or: notify.fish \"Description\"" | |
| exit 1 | |
| end | |
| set title "Status Update" | |
| if test (count $argv) -ge 2 | |
| set title $argv[1] | |
| set message (string join " " $argv[2..-1]) | |
| else | |
| set message $argv[1] | |
| end | |
| set -g use_host_exec 0 | |
| if set --query CONTAINER_ID; and type -q distrobox-host-exec | |
| set -g use_host_exec 1 | |
| end | |
| function run_cmd | |
| if test "$use_host_exec" = "1" | |
| distrobox-host-exec $argv | |
| else | |
| command $argv | |
| end | |
| end | |
| function send_ntfy | |
| set endpoint "http://100.127.86.108:8080/phone" | |
| if set --query NOTIFY_NTFY_ENDPOINT | |
| set endpoint $NOTIFY_NTFY_ENDPOINT | |
| end | |
| if type -q xh; and run_cmd xh --quiet --ignore-stdin --timeout 5 POST $endpoint Title:"$title" --raw "$message" >/dev/null 2>&1 | |
| return 0 | |
| end | |
| if type -q curl; and run_cmd curl -fsS --max-time 5 -H "Title: $title" -d "$message" $endpoint >/dev/null 2>&1 | |
| return 0 | |
| end | |
| return 1 | |
| end | |
| function supports_notify_action | |
| run_cmd notify-send --help 2>/dev/null | string match -rq -- '--action' | |
| end | |
| function focus_konsole_panel --argument-names service window session_path window_id | |
| set -l session_id (string replace -r '^/Sessions/' '' -- "$session_path") | |
| set -l switched 0 | |
| if string match -rq '^[0-9]+$' -- "$session_id" | |
| if type -q gdbus | |
| if run_cmd gdbus call --session --dest "$service" --object-path "$window" --method org.kde.konsole.Window.setCurrentSession "$session_id" >/dev/null 2>&1 | |
| set switched 1 | |
| end | |
| else if type -q qdbus | |
| if run_cmd qdbus "$service" "$window" setCurrentSession "$session_id" >/dev/null 2>&1 | |
| set switched 1 | |
| end | |
| end | |
| end | |
| if test -n "$window_id" | |
| if type -q wmctrl | |
| run_cmd wmctrl -ia "$window_id" >/dev/null 2>&1 | |
| else if type -q xdotool | |
| run_cmd xdotool windowactivate "$window_id" >/dev/null 2>&1 | |
| end | |
| end | |
| test "$switched" = "1" | |
| return $status | |
| end | |
| set -l notify_timeout_ms 5000 | |
| set -l notify_timeout_sec 5 | |
| function send_clickable_notify --argument-names timeout_ms timeout_sec title message | |
| if type -q timeout | |
| run_cmd timeout "$timeout_sec"s notify-send --app-name "System Monitor" --icon "preferences-desktop-notification-bell" --wait --expire-time "$timeout_ms" --action "default=Focus this Konsole panel" "$title" "$message" | |
| else | |
| run_cmd notify-send --app-name "System Monitor" --icon "preferences-desktop-notification-bell" --wait --expire-time "$timeout_ms" --action "default=Focus this Konsole panel" "$title" "$message" | |
| end | |
| end | |
| set locked false | |
| set lock_state (run_cmd busctl --user call org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver org.freedesktop.ScreenSaver GetActive 2>/dev/null) | |
| if test -n "$lock_state" | |
| set parts (string split ' ' -- $lock_state) | |
| if test (count $parts) -ge 2 | |
| set locked $parts[2] | |
| end | |
| end | |
| if test "$locked" = "true" | |
| set available_ids (run_cmd kdeconnect-cli --list-available --id-only 2>/dev/null) | |
| set target "" | |
| if set --query KDE_CONNECT_DEVICE_ID | |
| if contains -- $KDE_CONNECT_DEVICE_ID $available_ids | |
| set target $KDE_CONNECT_DEVICE_ID | |
| end | |
| else if test (count $available_ids) -gt 0 | |
| set target $available_ids[1] | |
| end | |
| if test -n "$target" | |
| if run_cmd kdeconnect-cli --device $target --ring --ping-msg "$title: $message" >/dev/null 2>&1 | |
| exit 0 | |
| end | |
| end | |
| if send_ntfy | |
| exit 0 | |
| end | |
| end | |
| set -l in_konsole 0 | |
| if set --query KONSOLE_DBUS_SERVICE; and set --query KONSOLE_DBUS_WINDOW; and set --query KONSOLE_DBUS_SESSION | |
| set in_konsole 1 | |
| end | |
| if test "$in_konsole" = "1"; and supports_notify_action | |
| set -l konsole_window_id "" | |
| if type -q xdotool | |
| set konsole_window_id (run_cmd xdotool getactivewindow 2>/dev/null) | |
| end | |
| set -l action (send_clickable_notify "$notify_timeout_ms" "$notify_timeout_sec" "$title" "$message") | |
| if test "$action" = "default" | |
| focus_konsole_panel "$KONSOLE_DBUS_SERVICE" "$KONSOLE_DBUS_WINDOW" "$KONSOLE_DBUS_SESSION" "$konsole_window_id" | |
| end | |
| else | |
| run_cmd notify-send --app-name "System Monitor" --icon "preferences-desktop-notification-bell" --expire-time "$notify_timeout_ms" "$title" "$message" | |
| end |
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
| #!/usr/bin/env bash | |
| set -u | |
| set -o pipefail | |
| focus_iterm_session() { | |
| local target_session_id="${1-}" | |
| local target_tty="${2-}" | |
| local normalized_session_id="${target_session_id##*:}" | |
| /usr/bin/osascript - "$target_session_id" "$normalized_session_id" "$target_tty" >/dev/null <<'APPLESCRIPT' | |
| on run argv | |
| set rawSessionId to item 1 of argv | |
| set normalizedSessionId to item 2 of argv | |
| set targetTTY to item 3 of argv | |
| set matchedWindowIndex to 0 | |
| set matchedTabIndex to 0 | |
| set matchedSessionId to "" | |
| tell application "iTerm2" | |
| set winCount to count of windows | |
| repeat with wi from 1 to winCount | |
| set w to window wi | |
| set tabCount to count of tabs of w | |
| repeat with ti from 1 to tabCount | |
| set t to tab ti of w | |
| repeat with s in sessions of t | |
| set sid to "" | |
| set suid to "" | |
| set stty to "" | |
| try | |
| set sid to (id of s as text) | |
| end try | |
| try | |
| set suid to (unique id of s as text) | |
| end try | |
| try | |
| set stty to (tty of s as text) | |
| end try | |
| set sessionMatch to false | |
| if normalizedSessionId is not "" then | |
| if sid is normalizedSessionId or suid is normalizedSessionId then | |
| set sessionMatch to true | |
| end if | |
| end if | |
| if sessionMatch is false and rawSessionId is not "" then | |
| if sid is rawSessionId or suid is rawSessionId then | |
| set sessionMatch to true | |
| end if | |
| end if | |
| set ttyMatch to false | |
| if targetTTY is not "" and stty is targetTTY then | |
| set ttyMatch to true | |
| end if | |
| if sessionMatch or ((rawSessionId is "" and normalizedSessionId is "") and ttyMatch) then | |
| set matchedWindowIndex to wi | |
| set matchedTabIndex to ti | |
| if suid is not "" then | |
| set matchedSessionId to suid | |
| else | |
| set matchedSessionId to sid | |
| end if | |
| exit repeat | |
| end if | |
| end repeat | |
| if matchedWindowIndex is not 0 then exit repeat | |
| end repeat | |
| if matchedWindowIndex is not 0 then exit repeat | |
| end repeat | |
| if matchedWindowIndex is 0 then return false | |
| set w to window matchedWindowIndex | |
| set t to tab matchedTabIndex of w | |
| activate | |
| tell w to select | |
| tell t to select | |
| if matchedSessionId is not "" then | |
| repeat with s in sessions of t | |
| try | |
| if (unique id of s as text) is matchedSessionId or (id of s as text) is matchedSessionId then | |
| tell s to select | |
| return true | |
| end if | |
| end try | |
| end repeat | |
| end if | |
| return true | |
| end tell | |
| return false | |
| end run | |
| APPLESCRIPT | |
| } | |
| resolve_self_path() { | |
| local source_path="${BASH_SOURCE[0]}" | |
| while [ -h "$source_path" ]; do | |
| local source_dir | |
| source_dir="$(cd -P "$(dirname -- "$source_path")" >/dev/null 2>&1 && pwd)" | |
| source_path="$(readlink "$source_path")" | |
| if [[ "$source_path" != /* ]]; then | |
| source_path="$source_dir/$source_path" | |
| fi | |
| done | |
| local final_dir | |
| final_dir="$(cd -P "$(dirname -- "$source_path")" >/dev/null 2>&1 && pwd)" | |
| printf '%s/%s\n' "$final_dir" "$(basename -- "$source_path")" | |
| } | |
| if [[ "${1-}" == "--focus" ]]; then | |
| focus_iterm_session "${2-}" "${3-}" | |
| exit 0 | |
| fi | |
| if (( $# < 2 )); then | |
| printf 'Usage: notify.sh <title> <message> [subtitle]\n' >&2 | |
| exit 2 | |
| fi | |
| title="$1" | |
| message="$2" | |
| subtitle="${3-Task Finished}" | |
| session_id="${ITERM_SESSION_ID-}" | |
| tty_path="" | |
| if tty_out="$(tty 2>/dev/null)"; then | |
| tty_path="$tty_out" | |
| fi | |
| group_key="default" | |
| if [[ -n "$session_id" ]]; then | |
| group_key="$session_id" | |
| elif [[ -n "$tty_path" ]]; then | |
| group_key="$tty_path" | |
| fi | |
| notify_group="notify-iterm-panel-$group_key" | |
| self_path="$(resolve_self_path)" | |
| if command -v alerter >/dev/null 2>&1; then | |
| nohup bash -c ' | |
| self_path="$1" | |
| session_id="$2" | |
| tty_path="$3" | |
| title="$4" | |
| subtitle="$5" | |
| message="$6" | |
| notify_group="$7" | |
| result="$(alerter --title "$title" --subtitle "$subtitle" --message "$message" --group "$notify_group" --sound default --actions Focus --close-label Ignore --timeout 600)" | |
| if [[ "$result" == "Focus" || "$result" == "@ACTIONCLICKED" || "$result" == "@CONTENTCLICKED" ]]; then | |
| "$self_path" --focus "$session_id" "$tty_path" >/dev/null 2>&1 | |
| fi | |
| ' _ "$self_path" "$session_id" "$tty_path" "$title" "$subtitle" "$message" "$notify_group" >/dev/null 2>&1 & | |
| elif command -v terminal-notifier >/dev/null 2>&1; then | |
| printf -v execute_cmd '%q --focus %q %q' "$self_path" "$session_id" "$tty_path" | |
| terminal-notifier \ | |
| -title "$title" \ | |
| -subtitle "$subtitle" \ | |
| -message "$message" \ | |
| -group "$notify_group" \ | |
| -sound default \ | |
| -execute "$execute_cmd" | |
| else | |
| /usr/bin/osascript - "$title" "$message" "$subtitle" <<'APPLESCRIPT' | |
| on run argv | |
| set t to item 1 of argv | |
| set m to item 2 of argv | |
| set s to item 3 of argv | |
| display notification m with title t subtitle s sound name "Crystal" | |
| end run | |
| APPLESCRIPT | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment