diff --git a/.cspell.config.yml b/.cspell.config.yml index c001e48..a75dacb 120000 --- a/.cspell.config.yml +++ b/.cspell.config.yml @@ -1 +1 @@ -/Users/thom.ribeiro/Desktop/interface/dotfiles/.cspell.config.yml \ No newline at end of file +/home/vacation/Desktop/interface/dotfiles/.cspell.config.yml \ No newline at end of file diff --git a/.gitignore b/.gitignore index d930128..ae71fcc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ bin/forex bin/presentvalue dotfiles/**/.uuid **/.DS_Store +dotfiles/.config/jj/repos \ No newline at end of file diff --git a/bin/firefox-music-sleep-fix b/bin/app-inhibit-sleep similarity index 66% rename from bin/firefox-music-sleep-fix rename to bin/app-inhibit-sleep index 911c781..4485343 100755 --- a/bin/firefox-music-sleep-fix +++ b/bin/app-inhibit-sleep @@ -5,19 +5,22 @@ # at https://opensource.org/license/BSD-3-clause. # # checks if firefox is playing music and inhibits idle, fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1665986 +# also checks other apps passed as arguments, and inhibits sleep for them too. # note: undefined functions are in lib.sh (sourced via BASH_ENV) # shellcheck disable=SC2155 set -euo pipefail shopt -s globstar -trap 'err $LINENO && cleanup' ERR +trap 'err $LINENO && cleanup' ERR INT TERM +trap 'cleanup' EXIT ### vars and functions ### readonly inhibition_duration_secs=65 readonly pooling_interval_secs=60 readonly playing="Playing" -child="" +apps=("$@") +children=() check_dependencies() { if [ -z "$BASH_ENV" ]; then @@ -36,8 +39,32 @@ help_exit() { } cleanup() { - # we do not care if child is already terminated - kill $child 2>/dev/null || true + local pid + + for pid in "${children[@]}"; do + # we do not care if the children is already terminated + kill "$pid" 2>/dev/null || true + done +} + +check_firefox_playback() { + # playerctl will error if there are no players, ignore that + local status + status=$(playerctl --player=plasma-browser-integration status 2>&1 || true) + + if [ "$status" = "$playing" ]; then + systemd-inhibit --what=idle --who="$0" --why='Firefox is playing audio' sleep $inhibition_duration_secs & + children+=("$!") + fi +} + +check_app_running() { + local app="$1" + + if pgrep --quiet --exact "$app" 2>&1; then + systemd-inhibit --what=idle --who="$0" --why="$app is running" sleep "$inhibition_duration_secs" & + children+=("$!") + fi } ### script ### @@ -50,13 +77,11 @@ if requested_help "$*"; then fi while true; do - # playerctl will error if there are no players, ignore that - status=$(playerctl --player=plasma-browser-integration status 2>&1 || true) + check_firefox_playback - if [ "$status" = $playing ]; then - systemd-inhibit --what=idle --who="$0" --why='Firefox is playing audio' sleep $inhibition_duration_secs & - child=$! - fi + for app in "${apps[@]}"; do + check_app_running "$app" + done sleep $pooling_interval_secs done diff --git a/bin/dictation-keyboard-hook b/bin/dictation-keyboard-hook new file mode 100755 index 0000000..dec1d28 --- /dev/null +++ b/bin/dictation-keyboard-hook @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +import sys, evdev, subprocess +from evdev import InputDevice, categorize, ecodes + +if len(sys.argv) != 3: + print(f"Usage: {sys.argv[0]} ") + print(f" key: e.g. KEY_F2") + print(f" device: e.g. /dev/input/by-id/usb-Keychron_Keychron_Q10-if02-event-kbd") + sys.exit(1) + +key = sys.argv[1] +device = InputDevice(sys.argv[2]) + +for event in device.read_loop(): + if event.type == ecodes.EV_KEY: + k = categorize(event) + if k.keycode == key: + if k.keystate == k.key_down: + subprocess.Popen(['/usr/bin/nerd-dictation', 'begin']) + elif k.keystate == k.key_up: + subprocess.Popen(['/usr/bin/nerd-dictation', 'end']) + diff --git a/bin/pacu b/bin/pacu index bf15616..8cff285 100755 --- a/bin/pacu +++ b/bin/pacu @@ -61,8 +61,6 @@ extract_version() { } migrate_postgres() { - local initdb_args=(--encoding=UTF8 -D /var/lib/postgres/data) old_version - msgln log $LINENO "manually migrating pg db across major versions..." log $LINENO "sudo required" @@ -77,9 +75,9 @@ migrate_postgres() { # todo: this may be broken because my user cant access /var/lib/postgres, it may be possible to pass --dir args to commands # note: needs testing -sudo -u postgres bash <<'EOF' + sudo -u postgres bash <<'EOF' cd /var/lib/postgres/tmp || exit 1 - sudo -u postgres initdb "${initdb_args[@]}" + sudo -u postgres initdb --encoding=UTF8 -D /var/lib/postgres/data sudo -u postgres pg_upgrade -b "/opt/pgsql-${old_version}/bin" -B /usr/bin -d /var/lib/postgres/olddata -D /var/lib/postgres/data EOF @@ -87,7 +85,7 @@ EOF } refresh_collations() { - local dbs=(comms comms_test hub hub_test member member_test vacation postgres) + local dbs=(comms comms_test hub hub_test member member_test postgres template1) log $LINENO collation update on "${dbs[*]}" @@ -208,12 +206,12 @@ kexec_prompt() { local response base_name=vmlinuz-linux suffix="${1:-}" local kernel_file="/boot/$base_name$suffix" initrd_file="/boot/initramfs-linux$suffix.img" - if ! stat "$kernel_file" >/dev/null 2>&1; then + if ! sudo stat "$kernel_file" >/dev/null 2>&1; then warn $LINENO "kernel file not found: $kernel_file" return fi - if ! stat "$initrd_file" >/dev/null 2>&1; then + if ! sudo stat "$initrd_file" >/dev/null 2>&1; then warn $LINENO "initramfs file not found: $initrd_file" return fi @@ -227,7 +225,7 @@ kexec_prompt() { fi } -cleanup_backgrounded_processes() { +cleanup_child_processes() { for pid in "${cleanup_processes[@]}"; do if ps -p "$pid" >/dev/null; then if ! kill -HUP "$pid"; then @@ -259,4 +257,4 @@ cleanup "$pg_update" kexec_prompt "" success_message -cleanup_backgrounded_processes +cleanup_child_processes diff --git a/dotfiles/.aliases.sh b/dotfiles/.aliases.sh index f33f089..29d249e 100644 --- a/dotfiles/.aliases.sh +++ b/dotfiles/.aliases.sh @@ -239,9 +239,9 @@ alias misc-="lg misc -" alias chore-="lg chore -" # jujutsu -alias jnm="jj new main" alias jgp="jj git push" alias jn="jj new" +alias gss="jss" # general alias la='ls -A' @@ -318,3 +318,4 @@ alias cd-="cd -" alias hexdump="hexdump -v -e '1/1 \"%02x \"'" alias urldecode="python3 -c \"import sys, urllib.parse; print(urllib.parse.unquote(sys.argv[1]))\"" alias unixnow="date +%s" +alias gmt="go mod tidy" diff --git a/dotfiles/.bashrc b/dotfiles/.bashrc index edab370..195321a 100644 --- a/dotfiles/.bashrc +++ b/dotfiles/.bashrc @@ -41,7 +41,7 @@ export GPG_TTY=$(tty) export XDG_RUNTIME_DIR export WAYLAND_DISPLAY # see lazy-git -export PUSH_REPOS="member-client interface priv hub-client server member-server shared go-athenahealth scheduling" +export PUSH_REPOS="member-client interface priv hub-client server member-server shared go-athenahealth scheduling jail-mcp" # libs src_dotfile "lib.sh" "$LINENO" diff --git a/dotfiles/.bashrc.mac.sh b/dotfiles/.bashrc.mac.sh index ed438b0..812638a 100644 --- a/dotfiles/.bashrc.mac.sh +++ b/dotfiles/.bashrc.mac.sh @@ -19,6 +19,7 @@ export PATH="\ $HOME/bin:\ /opt/homebrew/bin:\ /opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:\ +/Applications/Docker.app/Contents/Resources/bin:\ /usr/local/bin:\ /bin:\ /usr/bin:\ diff --git a/dotfiles/.config/Claude/claude_desktop_config.json b/dotfiles/.config/Claude/claude_desktop_config.json new file mode 100644 index 0000000..f641e86 --- /dev/null +++ b/dotfiles/.config/Claude/claude_desktop_config.json @@ -0,0 +1,25 @@ +{ + "mcpServers": { + "jail_MPC": { + "command": "docker", + "args": [ + "compose", + "-f", + "/home/vacation/Desktop/jail-mcp/docker-compose.yml", + "run", + "--rm", + "-i", + "jail-mcp" + ] + } + }, + "isUsingBuiltInNodeForMcp": false, + "preferences": { + "quickEntryShortcut": "off", + "quickEntryDictationShortcut": "capslock", + "coworkScheduledTasksEnabled": true, + "ccdScheduledTasksEnabled": true, + "sidebarMode": "chat", + "coworkWebSearchEnabled": true + } +} \ No newline at end of file diff --git a/dotfiles/.config/Claude/claude_desktop_config.mac.json b/dotfiles/.config/Claude/claude_desktop_config.mac.json new file mode 100644 index 0000000..37140cc --- /dev/null +++ b/dotfiles/.config/Claude/claude_desktop_config.mac.json @@ -0,0 +1,25 @@ +{ + "mcpServers": { + "jail_MPC": { + "command": "/Applications/Docker.app/Contents/Resources/bin/docker", + "args": [ + "compose", + "-f", + "/Users/thom.ribeiro/Desktop/jail-mcp/docker-compose.yml", + "run", + "--rm", + "-i", + "jail-mcp" + ] + } + }, + "isUsingBuiltInNodeForMcp": false, + "preferences": { + "quickEntryShortcut": "off", + "quickEntryDictationShortcut": "capslock", + "coworkScheduledTasksEnabled": true, + "ccdScheduledTasksEnabled": true, + "sidebarMode": "chat", + "coworkWebSearchEnabled": true + } +} \ No newline at end of file diff --git a/dotfiles/.config/code/User/keybindings.json b/dotfiles/.config/code/User/keybindings.json index ee0edfc..c35fc2c 100644 --- a/dotfiles/.config/code/User/keybindings.json +++ b/dotfiles/.config/code/User/keybindings.json @@ -717,5 +717,9 @@ "key": "shift+cmd+o", "command": "-workbench.action.gotoSymbol", "when": "!accessibilityHelpIsShown && !accessibleViewIsShown" + }, + { + "key": "cmd+-", + "command": "-workbench.action.zoomOut" } ] diff --git a/dotfiles/.config/jj/repos/c5ce47fa72721ebf42ef/metadata.binpb b/dotfiles/.config/jj/repos/c5ce47fa72721ebf42ef/metadata.binpb new file mode 100644 index 0000000..edd0b48 --- /dev/null +++ b/dotfiles/.config/jj/repos/c5ce47fa72721ebf42ef/metadata.binpb @@ -0,0 +1,2 @@ + +)/home/vacation/Desktop/interface/.jj/repo \ No newline at end of file diff --git a/dotfiles/.config/kdeglobals b/dotfiles/.config/kdeglobals index 4e3465c..74f7955 100644 --- a/dotfiles/.config/kdeglobals +++ b/dotfiles/.config/kdeglobals @@ -107,11 +107,6 @@ Size=48 [DialogIcons] Size=32 -[DirSelect Dialog] -DirSelectDialog Size=827,582 -History Items[$e]=file:///plex/anime,file:///media/ssd/games,file:///media/ssd,file:///media/data/Games/prefixes/core-keeper/drive_c/users/vacation/Desktop,file:$HOME/Desktop/go/sh/lib,file:$HOME/Desktop/sh,file:$HOME/Desktop/go,file:$HOME/Desktop/_old-repos/baristai,file:$HOME/desk/_old-repos/tcodes0/,file:$HOME/desk/assistd/,file:$HOME/Desktop/ollama,file:///media/data/Games,file:$HOME/docs,file:$HOME/Desktop/go-athenahealth,file:///media/data/Games/prefixes/cotl/drive_c/users/vacation/Desktop/,file:///media/data/Games/,file:$HOME/Desktop/shared,file:$HOME/Desktop/member-client,file:$HOME/Desktop/go-common,file:$HOME/Desktop/server,file:$HOME/Desktop//interface/,file:$HOME/Desktop//inter,file:$HOME/Desktop/tcodes0-go,file:///media/data/izi-stuff -Splitter State=\x00\x00\x00\xff\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x91\x00\x00\x02\xa8\x00\xff\xff\xff\xff\x01\x00\x00\x00\x01\x00 - [Emoticons] emoticonsTheme=EmojiOne parseMode=2 diff --git a/dotfiles/.config/systemd/user/firefox-music-sleep-fix.service b/dotfiles/.config/systemd/user/app-inhibit-sleep.service similarity index 60% rename from dotfiles/.config/systemd/user/firefox-music-sleep-fix.service rename to dotfiles/.config/systemd/user/app-inhibit-sleep.service index d8a553a..01c7d99 100644 --- a/dotfiles/.config/systemd/user/firefox-music-sleep-fix.service +++ b/dotfiles/.config/systemd/user/app-inhibit-sleep.service @@ -1,10 +1,10 @@ [Unit] -Description=Firefox music sleep fix service +Description=Inhibit sleep if firefox is playing music or other apps are running Wants=network-online.target After=network.target network-online.target [Service] -ExecStart=%h/bin/firefox-music-sleep-fix +ExecStart=%h/bin/app-inhibit-sleep pacman yay Environment="BASH_ENV=$HOME/.bash_env" Restart=always Type=simple diff --git a/dotfiles/.config/systemd/user/default.target.wants/app-inhibit-sleep.service b/dotfiles/.config/systemd/user/default.target.wants/app-inhibit-sleep.service new file mode 120000 index 0000000..62fc9d3 --- /dev/null +++ b/dotfiles/.config/systemd/user/default.target.wants/app-inhibit-sleep.service @@ -0,0 +1 @@ +/home/vacation/.config/systemd/user/app-inhibit-sleep.service \ No newline at end of file diff --git a/dotfiles/.config/systemd/user/default.target.wants/firefox-music-sleep-fix.service b/dotfiles/.config/systemd/user/default.target.wants/firefox-music-sleep-fix.service deleted file mode 120000 index 2e59e14..0000000 --- a/dotfiles/.config/systemd/user/default.target.wants/firefox-music-sleep-fix.service +++ /dev/null @@ -1 +0,0 @@ -/home/vacation/.config/systemd/user/firefox-music-sleep-fix.service \ No newline at end of file diff --git a/dotfiles/.config/systemd/user/dictation-shortcut.service b/dotfiles/.config/systemd/user/dictation-shortcut.service new file mode 100644 index 0000000..faf17d9 --- /dev/null +++ b/dotfiles/.config/systemd/user/dictation-shortcut.service @@ -0,0 +1,10 @@ +[Unit] +Description=Dictation shortcut on key down and key up + +[Service] +ExecStart=/usr/bin/python3 %h/bin/dictation-keyboard-hook KEY_F2 /dev/input/by-id/usb-Keychron_Keychron_Q10-if02-event-kbd +Restart=on-failure +Group=input + +[Install] +WantedBy=default.target diff --git a/dotfiles/.config/systemd/user/docker.service.d/override.conf b/dotfiles/.config/systemd/user/docker.service.d/override.conf new file mode 100644 index 0000000..0d0af0d --- /dev/null +++ b/dotfiles/.config/systemd/user/docker.service.d/override.conf @@ -0,0 +1,4 @@ +[Service] +Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_DISABLE_HOST_LOOPBACK=false" +# by default rootless kit starts slirp4netns with this flag true +# this prevents the containers from reaching the host network diff --git a/dotfiles/.config/systemd/user/multi-user.target.wants/firefox-music-sleep-fix.service b/dotfiles/.config/systemd/user/multi-user.target.wants/firefox-music-sleep-fix.service deleted file mode 120000 index d36e6ee..0000000 --- a/dotfiles/.config/systemd/user/multi-user.target.wants/firefox-music-sleep-fix.service +++ /dev/null @@ -1 +0,0 @@ -/home/vacation/Desktop/interface/dotfiles/.config/systemd/user/firefox-music-sleep-fix.service \ No newline at end of file diff --git a/dotfiles/.config/systemd/user/ollama.service b/dotfiles/.config/systemd/user/ollama.service index 6a3ed3a..bf12526 100644 --- a/dotfiles/.config/systemd/user/ollama.service +++ b/dotfiles/.config/systemd/user/ollama.service @@ -4,9 +4,16 @@ Wants=network-online.target After=network.target network-online.target [Service] -ExecStart=%h/bin/ollama serve -Restart=on-failure -RestartSec=10 +ExecStart=/usr/bin/ollama serve +Environment="ROCM_PATH=/opt/rocm" +Environment="HSA_PATH=/opt/rocm" +Environment="PATH=$PATH" +# listen on all network interfaces, not just localhost (default) +# makes local ollama visible to the docker bridge gateway +Environment="OLLAMA_HOST=0.0.0.0" +Environment="OLLAMA_KEEP_ALIVE=1h" +Restart=always +RestartSec=3 Type=simple [Install] diff --git a/dotfiles/.functions.sh b/dotfiles/.functions.sh index a289570..03a493d 100644 --- a/dotfiles/.functions.sh +++ b/dotfiles/.functions.sh @@ -131,25 +131,31 @@ yad() { #- - - - - - - - - - - +# when there's no repo, call ls instead jss() { - if command jj status 2>/dev/null 1>&2; then + if ! command jj root &>/dev/null; then + _git_gss "$@" + return $? + fi + + if command jj root &>/dev/null; then command jj status else warn $LINENO "not a jj root" ls fi + } -# fix calling git status when there's no repo, call ls instead -gss() { - jss +#- - - - - - - - - - - - # if command git status -s 2>/dev/null 1>&2; then - # command git status -s - # else - # warn $LINENO "not a git repo" - # ls - # fi +_git_gss() { + if command git status -s 2>/dev/null 1>&2; then + command git status -s + else + warn $LINENO "not a git repo" + ls + fi } #- - - - - - - - - - - @@ -164,7 +170,7 @@ grbonto() { #- - - - - - - - - - - -gcom() { +_git_gcom() { if ! git fetch --all --prune; then return fi @@ -188,6 +194,17 @@ gcom() { #---------------- +gcom() { + if ! command jj root &>/dev/null; then + _git_gcom "$@" + return $? + fi + + jnm +} + +#---------------- + gotest() { if [ "$#" -eq 0 ]; then echo "Usage: gotest path/to/test" @@ -368,34 +385,6 @@ jj_prompt() { #- - - - - - - - - - - -# Track recent bookmarks per repo using a global var. -# track_jj_bookmarks() { -# local repo="$1" current_bookmark="$2" - -# if [[ "$current_bookmark" == "main" || "$current_bookmark" == "master" ]]; then -# return -# fi - -# if [[ "${JJ_RECENT_BOOKMARK_MAP[$repo]+set}" == "" ]]; then -# JJ_RECENT_BOOKMARK_MAP[$repo]="" -# fi - -# local -a bookmarks=() -# read -ra bookmarks <<<"${JJ_RECENT_BOOKMARK_MAP[$repo]}" - -# if [[ "${bookmarks[0]}" != "$current_bookmark" ]]; then -# bookmarks=("$current_bookmark" "${bookmarks[@]}") -# fi - -# if [ "${#bookmarks[@]}" -gt 7 ]; then -# bookmarks=("${bookmarks[@]:0:7}") -# fi - -# JJ_RECENT_BOOKMARK_MAP["$repo"]="${bookmarks[*]}" -# } - -#- - - - - - - - - - - - # jj bookmark set private # $1 - bookmark name # $2 - revision @@ -404,6 +393,8 @@ __jj_bookmark_set() { jj bookmark set "$1" --revision "$2" "${@:3}" } +#---------------- + # jj bookmark set on @ jjb() { if [[ $# == 0 ]]; then @@ -415,6 +406,8 @@ jjb() { __jj_bookmark_set "$1" @ } +#---------------- + # jj bookmark set on @- jjb-() { if [[ $# == 0 ]]; then @@ -426,6 +419,8 @@ jjb-() { __jj_bookmark_set "$1" @- --allow-backwards } +#---------------- + # jj rebase --source $1 --destination $2 jjrb() { if [[ $# != 2 ]]; then @@ -436,6 +431,8 @@ jjrb() { jj rebase --source "$1" --destination "$2" } +#---------------- + # jj new @origin jno() { if [[ $# != 1 ]]; then @@ -456,20 +453,39 @@ jno() { __jj_bookmark_set "$1" @- --allow-backwards } +#---------------- + +jnm() { + if ! command jj root &>/dev/null; then + _git_gcom + return $? + fi + + if ! git fetch --all --prune; then + return + fi + + jj new main +} + +#---------------- + __npc() { - local branch=$1 backwards_flag="$2" today_date=$(date +"%b-%d" | tr '[:upper:]' '[:lower:]') + local branch=$1 backwards_flag="$2" today_date=$(date +"%b-%d" | tr '[:upper:]' '[:lower:]') prefix=px if [ "$backwards_flag" == "-" ]; then - jjb- "pc-$1-$today_date" + jjb- "$prefix-$1-$today_date" else - jjb "pc-$1-$today_date" + jjb "$prefix-$1-$today_date" fi } +#---------------- + # new PC ticket bookmark on @ npc() { if [[ $# != 1 ]]; then - echo "runs jj bookmark set pc- @" + echo "runs jj bookmark set px- @" echo "sufixes with today's date" return fi @@ -477,10 +493,12 @@ npc() { __npc "$1" } +#---------------- + # new PC ticket bookmark on @- npc-() { if [[ $# != 1 ]]; then - echo "runs jj bookmark set pc- @-" + echo "runs jj bookmark set px- @-" echo "sufixes with today's date" return fi @@ -488,6 +506,8 @@ npc-() { __npc "$1" - } +#---------------- + #url decode and json format urldecode_json() { if [ ! "$1" ]; then