Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell.config.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ bin/forex
bin/presentvalue
dotfiles/**/.uuid
**/.DS_Store
dotfiles/.config/jj/repos
45 changes: 35 additions & 10 deletions bin/firefox-music-sleep-fix → bin/app-inhibit-sleep
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ###
Expand All @@ -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
22 changes: 22 additions & 0 deletions bin/dictation-keyboard-hook
Original file line number Diff line number Diff line change
@@ -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]} <key> <device>")
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'])

16 changes: 7 additions & 9 deletions bin/pacu
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -77,17 +75,17 @@ 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

sudo chown postgres:postgres /var/lib/postgres/data /var/lib/postgres/tmp
}

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[*]}"

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -259,4 +257,4 @@ cleanup "$pg_update"
kexec_prompt ""
success_message

cleanup_backgrounded_processes
cleanup_child_processes
3 changes: 2 additions & 1 deletion dotfiles/.aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion dotfiles/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dotfiles/.bashrc.mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:\
Expand Down
25 changes: 25 additions & 0 deletions dotfiles/.config/Claude/claude_desktop_config.json
Original file line number Diff line number Diff line change
@@ -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
}
}
25 changes: 25 additions & 0 deletions dotfiles/.config/Claude/claude_desktop_config.mac.json
Original file line number Diff line number Diff line change
@@ -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
}
}
4 changes: 4 additions & 0 deletions dotfiles/.config/code/User/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,5 +717,9 @@
"key": "shift+cmd+o",
"command": "-workbench.action.gotoSymbol",
"when": "!accessibilityHelpIsShown && !accessibleViewIsShown"
},
{
"key": "cmd+-",
"command": "-workbench.action.zoomOut"
}
]
2 changes: 2 additions & 0 deletions dotfiles/.config/jj/repos/c5ce47fa72721ebf42ef/metadata.binpb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

)/home/vacation/Desktop/interface/.jj/repo
5 changes: 0 additions & 5 deletions dotfiles/.config/kdeglobals
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions dotfiles/.config/systemd/user/dictation-shortcut.service
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions dotfiles/.config/systemd/user/docker.service.d/override.conf
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

13 changes: 10 additions & 3 deletions dotfiles/.config/systemd/user/ollama.service
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading