diff options
| author | Mike Vink <ivi@vinkies.net> | 2025-10-23 20:41:59 +0200 |
|---|---|---|
| committer | Mike Vink <ivi@vinkies.net> | 2025-10-23 20:41:59 +0200 |
| commit | 29a759d2c7614cd4bea6f7f9b656120f87f60d33 (patch) | |
| tree | 0aad017fc8587998b1b752bbce5add529a3ea185 /.local | |
| parent | c4a45156bdac9a9c7eb4fb81767396114f368443 (diff) | |
scripts
Diffstat (limited to '.local')
| -rwxr-xr-x | .local/bin/kc | 2 | ||||
| -rwxr-xr-x | .local/bin/macos.d/dmenu | 2 | ||||
| -rwxr-xr-x | .local/bin/macos.d/dmenu_raycast | 55 | ||||
| -rwxr-xr-x | .local/bin/macos.d/ghostty-split.sh | 37 | ||||
| -rwxr-xr-x | .local/bin/macos.d/setbg | 4 | ||||
| -rwxr-xr-x | .local/bin/otpmenu | 4 | ||||
| -rwxr-xr-x | .local/bin/passmenu | 7 | ||||
| -rwxr-xr-x | .local/bin/pom | 2 |
8 files changed, 102 insertions, 11 deletions
diff --git a/.local/bin/kc b/.local/bin/kc index 4aed5f6..d8c84df 100755 --- a/.local/bin/kc +++ b/.local/bin/kc @@ -1,3 +1,3 @@ #!/bin/sh -ctx="$(nu --commands "open ${KUBECONFIG:-$HOME/.kube/config} | from yaml | get contexts.name | to text" | vis-menu)" +ctx="$(nu --commands "open ${KUBECONFIG:-$HOME/.kube/config} | from yaml | get contexts.name | to text" | $PICKER)" [ -z "$ctx" ] || kubectl config use-context "$ctx" diff --git a/.local/bin/macos.d/dmenu b/.local/bin/macos.d/dmenu index fdcf9bf..b9647b4 100755 --- a/.local/bin/macos.d/dmenu +++ b/.local/bin/macos.d/dmenu @@ -1,2 +1,2 @@ #!/bin/sh -exec vis-menu "$@" +exec dmenu_raycast "$@" diff --git a/.local/bin/macos.d/dmenu_raycast b/.local/bin/macos.d/dmenu_raycast new file mode 100755 index 0000000..30dc5da --- /dev/null +++ b/.local/bin/macos.d/dmenu_raycast @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +import asyncio +import subprocess +import json +import sys +from urllib.parse import urlencode, quote + +EXTENSION = "irth/dmenu" +COMMAND = "index" +HOST = "127.0.0.1" +PORT = 8888 + +SHUTDOWN_EVENT = asyncio.Event() + +elements = [el for el in list(sys.stdin) if not el.isspace()] + +async def handle_echo(reader, writer): + if not SHUTDOWN_EVENT.is_set(): + data_len = f"{len(elements)}\n".encode("utf-8") + writer.write(data_len) + for el in elements: + data_line = f"{el.strip()}\n".encode("utf-8") + writer.write(data_line) + await writer.drain() + + selection = await reader.read() + + writer.close() + await writer.wait_closed() + + sys.stdout.write(selection.decode()) + + SHUTDOWN_EVENT.set() + + +async def main(): + server = await asyncio.start_server(handle_echo, HOST, PORT) + + addrs = ", ".join(str(sock.getsockname()) for sock in server.sockets) + + async with server: + asyncio.create_task(server.serve_forever()) + + arguments = { + "host": HOST, + "port": str(PORT), + } + query = urlencode({"arguments": json.dumps(arguments)}, quote_via=quote) + url = f"raycast://extensions/{EXTENSION}/{COMMAND}?{query}" + await asyncio.create_subprocess_shell(f"open -g {url}") + + await SHUTDOWN_EVENT.wait() + + +asyncio.run(main()) diff --git a/.local/bin/macos.d/ghostty-split.sh b/.local/bin/macos.d/ghostty-split.sh new file mode 100755 index 0000000..36023e6 --- /dev/null +++ b/.local/bin/macos.d/ghostty-split.sh @@ -0,0 +1,37 @@ +#!/bin/bash + + +osa=' +on runCommandInteractively(theCommand) + tell application "Ghostty" to activate + + tell application "System Events" + tell process "Ghostty" + keystroke return using command down + end tell + end tell + delay 0.2 + + tell application "System Events" + keystroke ((" " & theCommand) as text) + keystroke return + end tell +end runCommandInteractively + +on run args +if class of args is list then -- arguments passed come in as a list + set quotedArgs to {} + repeat with arg in args + -- set end of quotedArgs to "'"'"'" & arg & "'"'"'" + set end of quotedArgs to "" & arg + end repeat + + set AppleScript'"'"'s text item delimiters to " " + set joinedArgs to quotedArgs as string + set AppleScript'"'"'s text item delimiters to "" + + runCommandInteractively(joinedArgs) +end if +end run +' +osascript -e "$osa" -- "$@" diff --git a/.local/bin/macos.d/setbg b/.local/bin/macos.d/setbg new file mode 100755 index 0000000..687a9f1 --- /dev/null +++ b/.local/bin/macos.d/setbg @@ -0,0 +1,4 @@ +#!/bin/sh +choice="$(ls ~/Wallpapers | dmenu)" || exit 1 +sed -i.bak 's,\(.*wallpaper": "\)\(.*\)\(".*\),\1'"$HOME/Wallpapers/$choice"'\3,' ~/.config/wal/colorschemes/dark/default.json +wal --theme default diff --git a/.local/bin/otpmenu b/.local/bin/otpmenu index b288b06..b43137d 100755 --- a/.local/bin/otpmenu +++ b/.local/bin/otpmenu @@ -1,8 +1,6 @@ #!/usr/bin/env bash shopt -s nullglob globstar -dmenu=dmenu -[ "$(uname)" = "Darwin" ] && dmenu=/Applications/dmenu-mac.app/Contents/MacOS/dmenu-mac copy() { xclip -f | xclip -f -sel c } @@ -17,7 +15,7 @@ password_files=( "$prefix"/**/*.gpg ) password_files=( "${password_files[@]#"$prefix"/}" ) password_files=( "${password_files[@]%.gpg}" ) -password="$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")" +password="$(printf '%s\n' "${password_files[@]}" | dmenu "$@")" [[ -n $password ]] || exit diff --git a/.local/bin/passmenu b/.local/bin/passmenu index f6c07ba..4a46b96 100755 --- a/.local/bin/passmenu +++ b/.local/bin/passmenu @@ -1,11 +1,6 @@ #!/usr/bin/env bash shopt -s nullglob globstar -dmenu=dmenu -[ "$(uname)" = "Darwin" ] && dmenu=/Applications/dmenu-mac.app/Contents/MacOS/dmenu-mac -copy() { - xclip -f | xclip -f -sel c -} if [ "$(uname)" = "Darwin" ]; then copy() { pbcopy @@ -19,7 +14,7 @@ fi password_files=( "${password_files[@]%.gpg}" ) echo "password_files: ${password_files[*]}" - password="$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")" + password="$(printf '%s\n' "${password_files[@]}" | dmenu "$@")" echo "password: $password" [[ -n $password ]] || exit diff --git a/.local/bin/pom b/.local/bin/pom new file mode 100755 index 0000000..16b0c79 --- /dev/null +++ b/.local/bin/pom @@ -0,0 +1,2 @@ +#!/bin/sh +setsid sh -c 'pomodoro start -w >/dev/null 2>&1 && notify-send "Pomodoro" "Break time!"' & |
