From 677b5ff214454fa18bc9abd0f48c521c69360c9e Mon Sep 17 00:00:00 2001 From: Paulo Alvares Date: Tue, 2 Jun 2026 02:33:25 +0100 Subject: [PATCH 1/3] feat: changes --- .bashaliasrc | 79 ++++++++++++++++++++++++++-- aliasfunctions/.bashgitrc | 76 +++++++++++++++++++++++++++ i3/config | 75 ++++++++++++++++++++++----- i3/{config_new => config_original} | 74 +++++--------------------- i3lockImage.sh | 34 +++++++----- scripts/.vscode/settings.json | 3 ++ scripts/auto-deb-update.sh | 32 ++++++++++++ scripts/notification-mute.sh | 2 +- scripts/tsh-cache-share.md | 83 ++++++++++++++++++++++++++++++ scripts/tsh-cache.sh | 79 ++++++++++++++++++++++++++++ 10 files changed, 446 insertions(+), 91 deletions(-) create mode 100644 aliasfunctions/.bashgitrc rename i3/{config_new => config_original} (74%) create mode 100644 scripts/.vscode/settings.json create mode 100755 scripts/auto-deb-update.sh create mode 100644 scripts/tsh-cache-share.md create mode 100755 scripts/tsh-cache.sh diff --git a/.bashaliasrc b/.bashaliasrc index 56845ce..a0d2c85 100644 --- a/.bashaliasrc +++ b/.bashaliasrc @@ -7,9 +7,6 @@ function editandsource(){ sourcefile $1 } alias esfile="editandsource" -function salias(){ - sourcefile ~/.bashaliasrc -} function ebash(){ editandsource ~/.bashrc @@ -20,6 +17,18 @@ function evim(){ function envim(){ nvimfolder ~/.config/nvim } +function etmux(){ + nvimfolder ~/.config/tmux +} +function ewezterm(){ + nvimfolder ~/.config/wezterm +} +function erego(){ + nvimfolder ~/.config/regolith3 +} +function e.conf(){ + nvimfolder ~/.config +} function ei3(){ nvim ~/.config/i3/config } @@ -36,6 +45,50 @@ function sbash(){ function ealias(){ editandsource $DOTFILES_PATH/.bashaliasrc } +function salias(){ + sourcefile $DOTFILES_PATH/.bashaliasrc +} + +source $DOTFILES_PATH/aliasfunctions/.bashgitrc + +function compass-teleport(){ + mongodb-compass mongodb://localhost:27017/%2A?directConnection=true&serverSelectionTimeoutMS=5000 + tsh proxy db --tunnel --port 27017 --db-user role/teleport-write $1 --db-name "*" +} +function tlp-p-app(){ + tsh proxy app $1 --port $2 +} +function tlp-mgmt-open(){ + local addr=$($DOTFILES_PATH/scripts/tsh-cache.sh mgmt --resolve "$1") + xdg-open "http://$addr" +} +declare -A _tsh_complete_map=( + [compass-teleport]=db + [tlp-p-app]=apps + [tlp-mgmt-open]=mgmt +) +_tsh_fzf_complete() { + if [[ $COMP_CWORD -eq 1 ]]; then + local resource="${_tsh_complete_map[${COMP_WORDS[0]}]}" + local apps + apps=$($DOTFILES_PATH/scripts/tsh-cache.sh "$resource") + + if command -v fzf &>/dev/null; then + local selected + selected=$(echo "$apps" | fzf --prompt="${COMP_WORDS[0]}> " --query="${COMP_WORDS[COMP_CWORD]}") + if [[ -n "$selected" ]]; then + COMPREPLY=("$selected") + fi + else + COMPREPLY=($(compgen -W "$apps" -- "${COMP_WORDS[COMP_CWORD]}")) + fi + fi +} +complete -F _tsh_fzf_complete compass-teleport +complete -F _tsh_fzf_complete tlp-p-app +complete -F _tsh_fzf_complete tlp-mgmt-open + +alias forceTlpAppsRefresh="$DOTFILES_PATH/scripts/tsh-cache.sh apps -f" # Directory aliases alias ..="cd .." @@ -48,15 +101,20 @@ alias damn="fuck" # docker compose alias alias dcu="docker compose up" alias dcub="docker compose up --build" +alias dcs="docker compose stop" alias dcd="docker compose down" alias dcdf="docker compose down -v --remove-orphans" # mvn alias alias mvnquarkus="mvn clean quarkus:dev -P.env" +alias mvnquarkusnoconsole="mvn clean quarkus:dev -P.env -Dquarkus.console.enabled='false'" +alias mvnquarkusnoconsolenotclean="mvn quarkus:dev -P.env -Dquarkus.console.enabled='false'" # xclip alias (clipboard) alias xc="xclip -selection clipboard" +# dunst refresh +alias dreset="killall dunst && notify-send test" # did not work as expected #function xc(){ # sh $1 | xclip -selection clipboard @@ -66,6 +124,16 @@ alias xc="xclip -selection clipboard" alias k9s-cluster-tools="k9s --kubeconfig ~/.kube/configThLiveToolsProd" alias k9s-eu-broker="k9s --kubeconfig ~/.kube/configeubrokermasterblaster" alias k9s-staging="k9s --kubeconfig ~/.kube/configstagmaster" +alias k9s-demo="k9s --kubeconfig ~/.kube/configdemo" +alias k9s-staging-gi="k9s --kubeconfig ~/.kube/configstagmastergi" +alias k9s-gmklocal="k9s --kubeconfig ~/.kube/configgmklocal" +alias k9s-idp-de-dev="KUBECONFIG=~/.kube/teleport-kubeconfig.yaml k9s" +alias k9s-idp-de-preprod="KUBECONFIG=~/.kube/teleport-kubeconfig-preprod.yaml k9s" +alias k9s-idp-de-prod="KUBECONFIG=~/.kube/teleport-kubeconfig-prod.yaml k9s" +alias ktlp="KUBECONFIG=~/.kube/teleport-kubeconfig.yaml kubectl" +alias ktlppre="KUBECONFIG=~/.kube/teleport-kubeconfig-preprod.yaml kubectl" +alias ktlpprod="KUBECONFIG=~/.kube/teleport-kubeconfig-prod.yaml kubectl" +alias kstg="KUBECONFIG=~/.kube/configstagmaster kubectl" alias watcher="ag -l | entr -rc" @@ -75,3 +143,8 @@ alias lg="lazygit" alias monitorDualLeft="xrandr --output HDMI1 --auto --left-of eDP1" alias monitorSingle="xrandr --auto" +alias howlongivebeenawake="uptime | awk -F'( |,|:)+' '{print \$6,\$7\",\",\$8,\"hours,\",\$9,\"minutes.\"}'" + +alias lgb="lazygit -p ~/bolttech/bgs-domain-collections" + +alias deb-install-from-folder="$DOTFILES_PATH/scripts/auto-deb-update.sh --confirm" diff --git a/aliasfunctions/.bashgitrc b/aliasfunctions/.bashgitrc new file mode 100644 index 0000000..49b97c3 --- /dev/null +++ b/aliasfunctions/.bashgitrc @@ -0,0 +1,76 @@ +function dalemarcio() { + local output + output=$(git push 2>&1) + local exit_code=$? + + echo "$output" + + if [ $exit_code -eq 0 ]; then + gpr-url + fi +} + +function gpr-url() { + local branch remote host owner repo path url + + branch=$(git symbolic-ref --short HEAD) || return 1 + remote=$(git config --get remote.origin.url) || return 1 + + # Shared parse: handles https://host/owner/repo(.git) and git@host:owner/repo(.git) + if [[ $remote =~ ^(https?|ssh)://[^/]+/(.+)/(.+?)(\.git)?$ ]]; then + host=$(sed -E 's#^[a-z]+://([^/]+)/.*#\1#' <<<"$remote") + owner="${BASH_REMATCH[2]}"; repo="${BASH_REMATCH[3]%.git}" + elif [[ $remote =~ ^.*@([^:]+):/*(.+)/(.+?)(\.git)?$ ]]; then + host="${BASH_REMATCH[1]}"; owner="${BASH_REMATCH[2]}"; repo="${BASH_REMATCH[3]%.git}" + else + echo "Unrecognized remote: $remote" >&2; return 1 + fi + + path="${owner}/${repo}" + # URL-encode the branch (handles feature/foo, etc.) + local from; from=$(_urlencode "$branch") + + # Ask where the PR should target: default branch or a selected one + local dest to="" + dest=$(printf '%s\n' "$branch -> Default branch" "$branch -> Select branch" "Cancel" \ + | fzf --prompt="Open PR: " --height=40%) + case "$dest" in + "$branch -> Select branch") + local target + target=$(git branch -r --format='%(refname:short)' \ + | sed 's#^origin/##' | grep -vx "HEAD\|$branch" | sort -u \ + | fzf --prompt="destination> " --height=40%) + [[ -z "$target" ]] && return 1 + to=$(_urlencode "$target") ;; + "$branch -> Default branch") ;; + *) return 1 ;; + esac + + case "$host" in + *github.com|*gitea*|*codeberg.org) + if [[ -n "$to" ]]; then url="https://${host}/${path}/compare/${to}...${from}?expand=1" + else url="https://${host}/${path}/compare/${from}?expand=1"; fi ;; + *gitlab.com) + url="https://${host}/${path}/-/merge_requests/new?merge_request%5Bsource_branch%5D=${from}" + [[ -n "$to" ]] && url+="&merge_request%5Btarget_branch%5D=${to}" ;; + *bitbucket.org) + url="https://${host}/${path}/pull-requests/new?source=${from}&t=1" + [[ -n "$to" ]] && url+="&dest=${to}" ;; + *) echo "Unknown host '$host' — remote: $remote" >&2; return 1 ;; + esac + + echo "$url" + xdg-open "$url" 2>/dev/null || open "$url" 2>/dev/null +} + +function _urlencode() { + local s="$1" out= c i + for (( i=0; i<${#s}; i++ )); do + c="${s:i:1}" + case "$c" in + [a-zA-Z0-9.~_-]) out+="$c" ;; + *) printf -v c '%%%02X' "'$c"; out+="$c" ;; + esac + done + printf '%s' "$out" +} diff --git a/i3/config b/i3/config index e5ef94a..37198f0 100644 --- a/i3/config +++ b/i3/config @@ -8,6 +8,7 @@ # i3 config file (v4) # # Please see https://i3wm.org/docs/userguide.html for a complete reference! +focus_on_window_activation urgent set $mod Mod4 @@ -41,15 +42,32 @@ bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status +# Use Script to adjust spotify volume +bindsym $mod+XF86AudioRaiseVolume exec --no-startup-id sh $HOME/spotify_control vup 0.05 && $refresh_i3status +bindsym $mod+XF86AudioLowerVolume exec --no-startup-id sh $HOME/spotify_control vdown 0.05 && $refresh_i3status +bindsym $mod+Ctrl+Mod2+KP_2 exec --no-startup-id sh $HOME/spotify_control playpause + +bindsym $mod+Shift+period exec --no-startup-id sh $HOME/spotify_control vup 0.05 && $refresh_i3status +bindsym $mod+Shift+m exec --no-startup-id sh $HOME/spotify_control vdown 0.05 && $refresh_i3status +bindsym $mod+Shift+comma exec --no-startup-id sh $HOME/spotify_control playpause + +# Use playerctl to control music players +bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause +bindsym XF86AudioNext exec --no-startup-id playerctl next && $refresh_i3status +bindsym XF86AudioPrev exec --no-startup-id playerctl previous + +bindsym $mod+z exec env XDG_CURRENT_DESKTOP=GNOME gnome-control-center + # Use Mouse+$mod to drag floating windows to their wanted position floating_modifier $mod # move tiling windows via drag & drop by left-clicking into the title bar, # or left-clicking anywhere into the window while holding the floating modifier. -# tiling_drag modifier titlebar +tiling_drag modifier titlebar # start a terminal bindsym $mod+Return exec i3-sensible-terminal +bindsym $mod+Ctrl+Return exec kitty # kill focused window bindsym $mod+Shift+q kill @@ -57,7 +75,6 @@ bindsym $mod+Shift+q kill # start dmenu (a program launcher) bindsym $mod+d exec --no-startup-id dmenu_run bindsym $mod+Shift+d exec --no-startup-id i3-dmenu-desktop - # A more modern dmenu replacement is rofi: # bindcode $mod+40 exec "rofi -modi drun,run -show drun" # There also is i3-dmenu-desktop which only displays applications shipping a @@ -188,10 +205,11 @@ bindsym $mod+r mode "resize" # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { - status_command i3status + status_command i3status | ~/dev/dotfiles/i3statusWrapper.py } -set $Locker i3lock -c 111111 && sleep 1 +# set $Locker i3lock -c 111111 && sleep 1 +set $Locker ~/dev/dotfiles/i3lockImage.sh set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown mode "$mode_system" { @@ -213,10 +231,10 @@ bindsym $mod+Ctrl+Shift+x mode "$mode_system" # Set the shortcuts and what they do set $mode_display Ext Screen (h) HDMI ON LEFT, (u) HDMI ON TOP, (k) HDMI ON RIGHT, (j) HDMI OFF mode "$mode_display" { - bindsym h exec --no-startup-id xrandr --output HDMI-1 --auto --left-of eDP-1, mode "default" - bindsym u exec --no-startup-id xrandr --output HDMI-1 --auto --above eDP-1, mode "default" - bindsym k exec --no-startup-id xrandr --output HDMI-1 --auto --right-of eDP-1, mode "default" - bindsym j exec --no-startup-id xrandr --output HDMI-1 --auto --off, mode "default" + bindsym h exec --no-startup-id xrandr --output HDMI1 --auto --left-of eDP1, mode "default" + bindsym k exec --no-startup-id xrandr --output HDMI1 --auto --above eDP1, mode "default" + bindsym l exec --no-startup-id xrandr --output HDMI1 --auto --right-of eDP1, mode "default" + bindsym j exec --no-startup-id xrandr --output HDMI1 --auto --off, mode "default" # back to normal: Enter or Escape bindsym Return mode "default" @@ -226,34 +244,63 @@ mode "$mode_display" { bindsym $mod+x mode "$mode_display" # Moving workspaces between screens -bindsym $mod+p move workspace to output left +bindsym $mod+p move workspace to output next # Notification system configuration for dunst (config @ ~/.config/dunst/dunstrc) bindsym $mod+n exec --no-startup-id dunstctl action bindsym $mod+Shift+n exec --no-startup-id dunstctl history-pop bindsym $mod+Ctrl+n exec --no-startup-id dunstctl close-all +bindsym $mod+Ctrl+Shift+n exec --no-startup-id dunstctl set-paused toggle && $refresh_i3status # General bindings bindsym $mod+Shift+s exec --no-startup-id flameshot gui bindsym $mod+Ctrl+l exec --no-startup-id $Locker # Specific containers for applications -for_window [class="Spotify"] move container to workspace $ws9 +for_window [class="Spotify"] move container to workspace $ws8 for_window [class="(?i)discord"] move container to workspace $ws10 -for_window [class="Slack"] move container to workspace $ws8 +for_window [class="Slack"] move container to workspace $ws9 # for_window [class="Slack"] move container to scratchpad, [class="Slack"] scratchpad show for_window [class="(?i)teams-for-linux"] move container to workspace $ws7 # Scratchpads bindsym $mod+Shift+minus move scratchpad bindsym $mod+minus scratchpad show -# Scratchpads for applications -bindsym $mod+Mod2+KP_1 [title="Slack$"] scratchpad show +# Scratchpads for applications (Mod2 is NumLock) +bindsym $mod+Mod2+KP_1 [class="Slack"] scratchpad show +bindsym $mod+u [class="Slack"] scratchpad show bindsym $mod+Mod2+KP_2 [class="Spotify"] scratchpad show +bindsym $mod+i [class="Spotify"] scratchpad show bindsym $mod+Mod2+KP_3 [title="(?i)teams"] scratchpad show +bindsym $mod+o [title="(?i)teams"] scratchpad show +bindsym XF86Calculator exec --no-startup-id rofi -show calc -modi calc -no-show-match -no-sort +bindsym $mod+Mod2+KP_9 exec --no-startup-id rofi -show calc -modi calc -no-show-match -no-sort + +# emoji picker +bindsym $mod+period exec --no-startup-id rofimoji + +# Terminal shortcuts, still needs to improove, leaving what kinda works for now +# Only works when there is already a terminal open +# set $terminal_shortcuts Open Notes (e) +# mode "$terminal_shortcuts" { +# bindsym e exec i3-sensible-terminal -e 'nvim $HOME/bolttech/Notes', mode "default" +# +# bindsym Return mode "default" +# bindsym Escape mode "default" +# } +# bindsym $mod+t mode "$terminal_shortcuts" # Start applications exec --no-startup-id nitrogen --restore exec --no-startup-id blueman-applet exec --no-startup-id blueman-tray -exec_always --no-startup-id compton +exec --no-startup-id compton +exec --no-startup-id /usr/bin/gnome-keyring-daemon --start --components=ssh,secrets,pkcs11,gpg + +# Start Applications on Weekdays +exec --no-startup-id test $(date +%u) -lt 6 && slack +exec --no-startup-id test $(date +%u) -lt 6 && teams-for-linux +exec --no-startup-id discord + +bindsym $mod+Shift+Return exec --no-startup-id terminator --working-directory "$(xcwd)" +# sway diff --git a/i3/config_new b/i3/config_original similarity index 74% rename from i3/config_new rename to i3/config_original index 5724c34..e5ef94a 100644 --- a/i3/config_new +++ b/i3/config_original @@ -41,32 +41,15 @@ bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status -# Use Script to adjust spotify volume -bindsym $mod+XF86AudioRaiseVolume exec --no-startup-id sh $HOME/spotify_control vup 0.05 && $refresh_i3status -bindsym $mod+XF86AudioLowerVolume exec --no-startup-id sh $HOME/spotify_control vdown 0.05 && $refresh_i3status -bindsym $mod+Ctrl+Mod2+KP_2 exec --no-startup-id sh $HOME/spotify_control playpause - -bindsym $mod+Shift+period exec --no-startup-id sh $HOME/spotify_control vup 0.05 && $refresh_i3status -bindsym $mod+Shift+m exec --no-startup-id sh $HOME/spotify_control vdown 0.05 && $refresh_i3status -bindsym $mod+Shift+comma exec --no-startup-id sh $HOME/spotify_control playpause - -# Use playerctl to control music players -bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause -bindsym XF86AudioNext exec --no-startup-id playerctl next && $refresh_i3status -bindsym XF86AudioPrev exec --no-startup-id playerctl previous - -bindsym $mod+z exec env XDG_CURRENT_DESKTOP=GNOME gnome-control-center - # Use Mouse+$mod to drag floating windows to their wanted position floating_modifier $mod # move tiling windows via drag & drop by left-clicking into the title bar, # or left-clicking anywhere into the window while holding the floating modifier. -tiling_drag modifier titlebar +# tiling_drag modifier titlebar # start a terminal bindsym $mod+Return exec i3-sensible-terminal -bindsym $mod+Ctrl+Return exec kitty # kill focused window bindsym $mod+Shift+q kill @@ -74,6 +57,7 @@ bindsym $mod+Shift+q kill # start dmenu (a program launcher) bindsym $mod+d exec --no-startup-id dmenu_run bindsym $mod+Shift+d exec --no-startup-id i3-dmenu-desktop + # A more modern dmenu replacement is rofi: # bindcode $mod+40 exec "rofi -modi drun,run -show drun" # There also is i3-dmenu-desktop which only displays applications shipping a @@ -204,11 +188,10 @@ bindsym $mod+r mode "resize" # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { - status_command i3status | ~/dev/dotfiles/i3statusWrapper.py + status_command i3status } -# set $Locker i3lock -c 111111 && sleep 1 -set $Locker ~/dev/dotfiles/i3lockImage.sh +set $Locker i3lock -c 111111 && sleep 1 set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown mode "$mode_system" { @@ -230,10 +213,10 @@ bindsym $mod+Ctrl+Shift+x mode "$mode_system" # Set the shortcuts and what they do set $mode_display Ext Screen (h) HDMI ON LEFT, (u) HDMI ON TOP, (k) HDMI ON RIGHT, (j) HDMI OFF mode "$mode_display" { - bindsym h exec --no-startup-id xrandr --output HDMI1 --auto --left-of eDP1, mode "default" - bindsym k exec --no-startup-id xrandr --output HDMI1 --auto --above eDP1, mode "default" - bindsym l exec --no-startup-id xrandr --output HDMI1 --auto --right-of eDP1, mode "default" - bindsym j exec --no-startup-id xrandr --output HDMI1 --auto --off, mode "default" + bindsym h exec --no-startup-id xrandr --output HDMI-1 --auto --left-of eDP-1, mode "default" + bindsym u exec --no-startup-id xrandr --output HDMI-1 --auto --above eDP-1, mode "default" + bindsym k exec --no-startup-id xrandr --output HDMI-1 --auto --right-of eDP-1, mode "default" + bindsym j exec --no-startup-id xrandr --output HDMI-1 --auto --off, mode "default" # back to normal: Enter or Escape bindsym Return mode "default" @@ -243,63 +226,34 @@ mode "$mode_display" { bindsym $mod+x mode "$mode_display" # Moving workspaces between screens -bindsym $mod+p move workspace to output next +bindsym $mod+p move workspace to output left # Notification system configuration for dunst (config @ ~/.config/dunst/dunstrc) bindsym $mod+n exec --no-startup-id dunstctl action bindsym $mod+Shift+n exec --no-startup-id dunstctl history-pop bindsym $mod+Ctrl+n exec --no-startup-id dunstctl close-all -bindsym $mod+Ctrl+Shift+n exec --no-startup-id dunstctl set-paused toggle && $refresh_i3status # General bindings bindsym $mod+Shift+s exec --no-startup-id flameshot gui bindsym $mod+Ctrl+l exec --no-startup-id $Locker # Specific containers for applications -for_window [class="Spotify"] move container to workspace $ws8 +for_window [class="Spotify"] move container to workspace $ws9 for_window [class="(?i)discord"] move container to workspace $ws10 -for_window [class="Slack"] move container to workspace $ws9 +for_window [class="Slack"] move container to workspace $ws8 # for_window [class="Slack"] move container to scratchpad, [class="Slack"] scratchpad show for_window [class="(?i)teams-for-linux"] move container to workspace $ws7 # Scratchpads bindsym $mod+Shift+minus move scratchpad bindsym $mod+minus scratchpad show -# Scratchpads for applications (Mod2 is NumLock) -bindsym $mod+Mod2+KP_1 [class="Slack"] scratchpad show -bindsym $mod+u [class="Slack"] scratchpad show +# Scratchpads for applications +bindsym $mod+Mod2+KP_1 [title="Slack$"] scratchpad show bindsym $mod+Mod2+KP_2 [class="Spotify"] scratchpad show -bindsym $mod+i [class="Spotify"] scratchpad show bindsym $mod+Mod2+KP_3 [title="(?i)teams"] scratchpad show -bindsym $mod+o [title="(?i)teams"] scratchpad show -bindsym XF86Calculator exec --no-startup-id rofi -show calc -modi calc -no-show-match -no-sort -bindsym $mod+Mod2+KP_9 exec --no-startup-id rofi -show calc -modi calc -no-show-match -no-sort - -# emoji picker -bindsym $mod+period exec --no-startup-id rofimoji - -# Terminal shortcuts, still needs to improove, leaving what kinda works for now -# Only works when there is already a terminal open -# set $terminal_shortcuts Open Notes (e) -# mode "$terminal_shortcuts" { -# bindsym e exec i3-sensible-terminal -e 'nvim $HOME/bolttech/Notes', mode "default" -# -# bindsym Return mode "default" -# bindsym Escape mode "default" -# } -# bindsym $mod+t mode "$terminal_shortcuts" # Start applications exec --no-startup-id nitrogen --restore exec --no-startup-id blueman-applet exec --no-startup-id blueman-tray -exec --no-startup-id compton -exec --no-startup-id /usr/bin/gnome-keyring-daemon --start --components=ssh,secrets,pkcs11,gpg - -# Start Applications on Weekdays -exec --no-startup-id test $(date +%u) -lt 6 && slack -exec --no-startup-id test $(date +%u) -lt 6 && teams-for-linux -exec --no-startup-id discord - -bindsym $mod+Shift+Return exec --no-startup-id terminator --working-directory "$(xcwd)" -# sway +exec_always --no-startup-id compton diff --git a/i3lockImage.sh b/i3lockImage.sh index f54a201..fec600c 100755 --- a/i3lockImage.sh +++ b/i3lockImage.sh @@ -13,7 +13,7 @@ IMAGE=/tmp/i3lock.png rm $IMAGE -SCREENSHOT="scrot $IMAGE" # 0.46s +SCREENSHOT="scrot $IMAGE" # 0.26s # Alternate screenshot method with imagemagick. NOTE: it is much slower # SCREENSHOT="import -window root $IMAGE" # 1.35s @@ -22,31 +22,39 @@ SCREENSHOT="scrot $IMAGE" # 0.46s # Uncomment one to use, if you have multiple, the last one will be used # All options are here: http://www.imagemagick.org/Usage/blur/#blur_args -BLURTYPE="0x8" # 7.52s -#BLURTYPE="0x2" # 4.39s -#BLURTYPE="5x2" # 3.80s -# BLURTYPE="2x8" # 2.90s -#BLURTYPE="2x3" # 2.92s +BLURTYPE="0x8" # 1.41s +#BLURTYPE="0x2" # 0.60s +#BLURTYPE="5x2" # 0.53s +# BLURTYPE="2x8" # 0.38s +#BLURTYPE="2x3" # 0.37s # Get the screenshot, add the blur and lock the screen with it $SCREENSHOT SIZE=`identify $IMAGE | cut -f 3 -d " "` echo $SIZE -R=$((RANDOM % 2)) +RSIZE=`echo $SIZE | awk -Fx '{print $2 "x" $1}'` +PSIZE=`echo $SIZE | awk -Fx '{print "1x" $2}'` +R=$((RANDOM % 5)) case $R in - # 0) - # # head injury lock - # convert $IMAGE \( -size $SIZE gradient: -rotate -270 \) \( -size 1x1440 gradient: -spread 128 -scale $SIZE\! \) -compose Distort -define compose:args='' -composite $IMAGE - # ;; 0) + # head injury lock + convert $IMAGE \( -size $RSIZE gradient: -rotate -270 \) \( -size $PSIZE gradient: -spread 128 -scale $SIZE\! \) -compose Distort -define compose:args='' -composite -flip $IMAGE #0.89 + ;; + 1 | 2) # pixelated lock - convert $IMAGE -sample 7% -scale $SIZE\! $IMAGE + convert $IMAGE -sample 7% -scale $SIZE\! $IMAGE #0.29s ;; *) # blurred lock convert $IMAGE -blur $BLURTYPE $IMAGE esac # xdg-open $IMAGE -i3lock -i $IMAGE +i3lock -i $IMAGE -p win # 1440 4480 # rm $IMAGE +sleep 10 +while [ $(pgrep i3lock -x | wc -l ) -ne 0 ]; +do + xset dpms force off + sleep 60 +done diff --git a/scripts/.vscode/settings.json b/scripts/.vscode/settings.json new file mode 100644 index 0000000..edc55ce --- /dev/null +++ b/scripts/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "snyk.advanced.autoSelectOrganization": true +} \ No newline at end of file diff --git a/scripts/auto-deb-update.sh b/scripts/auto-deb-update.sh new file mode 100755 index 0000000..f3b2ecf --- /dev/null +++ b/scripts/auto-deb-update.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Path to your manually downloaded .deb packages +DEB_DIR="$HOME/deb-updates" +INSTALLED_TAG="installed-" +CONFIRM=false +[[ "$1" == "--confirm" ]] && CONFIRM=true +COLS=$(tput cols 2>/dev/null || echo 40) +LINE=$(printf '═%.0s' $(seq 1 "$COLS")) + +# Check for .deb files that haven't been installed yet +if find "$DEB_DIR" -maxdepth 1 -name "*.deb" ! -name "${INSTALLED_TAG}*" | grep -q .; then + for deb in "$DEB_DIR"/*.deb; do + [[ "$(basename "$deb")" == ${INSTALLED_TAG}* ]] && continue + if $CONFIRM; then + read -p "Install $(basename "$deb")? [y/N] " ans + [[ "$ans" != [yY] ]] && continue + fi + echo -e "\n$LINE" + echo " đŸ“Ļ Installing: $(basename "$deb")" + echo "$LINE" + sudo dpkg -i "$deb" && mv "$deb" "$DEB_DIR/${INSTALLED_TAG}$(basename "$deb")" && echo -e "$LINE\n ✅ $(basename "$deb") installed successfully\n$LINE\n" + done + echo -e "\n$LINE" + echo " 🔧 Fixing missing dependencies..." + echo "$LINE" + sudo apt-get install -f -y + echo -e "$LINE\n ✅ Dependencies resolved\n$LINE\n" +else + echo -e "\n$LINE" + echo " â„šī¸ No new .deb packages found in $DEB_DIR" + echo -e "$LINE\n" +fi diff --git a/scripts/notification-mute.sh b/scripts/notification-mute.sh index be852f5..56658a3 100755 --- a/scripts/notification-mute.sh +++ b/scripts/notification-mute.sh @@ -15,7 +15,7 @@ state=$(gsettings get org.gnome.desktop.notifications show-banners) if [[ $state == 'true' ]] then notify-send "Notifications: disabled"; - sleep 0.1; + sleep 0.3; gsettings set org.gnome.desktop.notifications show-banners false else gsettings set org.gnome.desktop.notifications show-banners true diff --git a/scripts/tsh-cache-share.md b/scripts/tsh-cache-share.md new file mode 100644 index 0000000..b5ffa32 --- /dev/null +++ b/scripts/tsh-cache-share.md @@ -0,0 +1,83 @@ +Something to make your life easier while working with IDP + teleport: + +I made a small script + bash snippet that gives you **Tab autocomplete** for teleport commands like `compass-teleport` and `tlp-p-app` (tsh proxy app). + +It caches the list of available apps/databases locally and refreshes every 24h, so you don't have to wait for `tsh` to fetch the list every time you hit Tab. + +**What you get:** +- `compass-teleport ` → autocomplete with available mongo databases +- `tlp-p-app ` → autocomplete with available teleport apps +- `tlp-mgmt-open ` → autocomplete with mgmt cluster apps, opens the app URL in the browser +- If you have `fzf` installed, you get a fuzzy search picker. If not, it falls back to standard bash prefix matching. + +**Setup:** + +1. Drop the attached `tsh-cache.sh` script somewhere in your path (e.g. `~/scripts/tsh-cache.sh`) and make it executable: +```bash +chmod +x ~/scripts/tsh-cache.sh +``` + +2. Add the snippet below to your `.bashrc` (or wherever you keep aliases/functions). Update `$DOTFILES_PATH/scripts/tsh-cache.sh` to match wherever you placed the script. + +3. Source your `.bashrc` or open a new terminal. + +**Snippet:** + +```bash +function compass-teleport(){ + mongodb-compass mongodb://localhost:27017/%2A?directConnection=true&serverSelectionTimeoutMS=5000 + tsh proxy db --tunnel --port 27017 --db-user role/teleport-write $1 --db-name "*" +} + +function tlp-p-app(){ + tsh proxy app $1 --port $2 +} + +function tlp-mgmt-open(){ + local addr=$($HOME/scripts/tsh-cache.sh mgmt --resolve "$1") + xdg-open "http://$addr" +} + +declare -A _tsh_complete_map=( + [compass-teleport]=db + [tlp-p-app]=apps + [tlp-mgmt-open]=mgmt +) + +_tsh_fzf_complete() { + if [[ $COMP_CWORD -eq 1 ]]; then + local resource="${_tsh_complete_map[${COMP_WORDS[0]}]}" + local apps + apps=$($HOME/scripts/tsh-cache.sh "$resource") + + if command -v fzf &>/dev/null; then + local selected + selected=$(echo "$apps" | fzf --prompt="${COMP_WORDS[0]}> " --query="${COMP_WORDS[COMP_CWORD]}") + if [[ -n "$selected" ]]; then + COMPREPLY=("$selected") + fi + else + COMPREPLY=($(compgen -W "$apps" -- "${COMP_WORDS[COMP_CWORD]}")) + fi + fi +} + +complete -F _tsh_fzf_complete compass-teleport +complete -F _tsh_fzf_complete tlp-p-app +complete -F _tsh_fzf_complete tlp-mgmt-open +``` + +**Tips:** +- First run may take a moment (tsh needs to fetch the list and might trigger a login). +- After that it's instant — results are cached at `~/.cache/tsh/`. +- To force a cache refresh: `tsh-cache.sh --force apps` or `tsh-cache.sh --force db`. +- To add autocomplete to other tsh commands, just add an entry to `_tsh_complete_map` and a `complete -F` line. +- `tlp-mgmt-open` uses `--resolve` to look up the app's public address from the cache and opens it in the browser. + +**Dependencies:** +- `jq` (required) — command-line JSON processor, used to parse tsh output +- `fzf` (optional) — fuzzy finder for the interactive search picker + +```bash +sudo apt install jq fzf +``` diff --git a/scripts/tsh-cache.sh b/scripts/tsh-cache.sh new file mode 100755 index 0000000..6199b15 --- /dev/null +++ b/scripts/tsh-cache.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# Configuration +CACHE_DIR="${HOME}/.cache/tsh" +CACHE_MAX_AGE=$((24 * 60 * 60)) # 24 hours in seconds + +# Parse flags and arguments +FORCE_RELOAD=false +RESOURCE_TYPE="" +RESOLVE_NAME="" + +while [[ $# -gt 0 ]]; do + case "$1" in + -f|--force) FORCE_RELOAD=true; shift ;; + --resolve) RESOLVE_NAME="$2"; shift 2 ;; + *) RESOURCE_TYPE="$1"; shift ;; + esac +done + +if [[ -z "$RESOURCE_TYPE" ]]; then + echo "Usage: tsh-cache.sh [-f|--force] [--resolve ] " >&2 + echo "Examples: tsh-cache.sh apps | tsh-cache.sh db | tsh-cache.sh mgmt --resolve app-name" >&2 + exit 1 +fi + +# --resolve is only valid for mgmt +if [[ -n "$RESOLVE_NAME" ]] && [[ "$RESOURCE_TYPE" != "mgmt" ]]; then + echo "Error: --resolve is only supported for 'mgmt' resource type" >&2 + exit 1 +fi + +CACHE_FILE="${CACHE_DIR}/${RESOURCE_TYPE}.txt" + +# Ensure cache directory exists +mkdir -p "$CACHE_DIR" + +# Check if cache exists and is less than 24 hours old +if [[ "$FORCE_RELOAD" == false ]] && [[ -f "$CACHE_FILE" ]]; then + file_age=$(( $(date +%s) - $(stat -c %Y "$CACHE_FILE") )) + if (( file_age < CACHE_MAX_AGE )); then + if [[ -n "$RESOLVE_NAME" ]]; then + awk -F'\t' -v name="$RESOLVE_NAME" '$1 == name { print $2 }' "$CACHE_FILE" + else + cut -f1 "$CACHE_FILE" + fi + exit 0 + fi +fi + +# Build command with resource-specific flags +# For "mgmt", we query apps but filter to mgmt cluster only +TSH_RESOURCE="$RESOURCE_TYPE" +TSH_CMD=(tsh "$TSH_RESOURCE" ls --format=json) +case "$RESOURCE_TYPE" in + db) TSH_CMD+=(--search mongo) ;; + mgmt) TSH_CMD=(tsh apps ls --format=json) ;; +esac + +# Apply resource-specific jq filters +# "mgmt" stores namepublic_addr for resolution +JQ_FILTER='.[].metadata.name' +case "$RESOURCE_TYPE" in + apps) JQ_FILTER='[.[] | select(.metadata.labels.cluster_name != "mgmt")] | .[].metadata.name' ;; + mgmt) JQ_FILTER='[.[] | select(.metadata.labels.cluster_name == "mgmt")] | .[] | "\(.metadata.name)\t\(.spec.public_addr)"' ;; +esac + +# Refresh: run tsh command in JSON format to avoid truncation +# Strip any non-JSON lines (e.g. login prompts) before the JSON array +"${TSH_CMD[@]}" 2>/dev/null \ + | sed -n '/^\[/,$p' \ + | jq -r "$JQ_FILTER" \ + > "$CACHE_FILE" + +# Output: resolve a name or list names +if [[ -n "$RESOLVE_NAME" ]]; then + awk -F'\t' -v name="$RESOLVE_NAME" '$1 == name { print $2 }' "$CACHE_FILE" +else + cut -f1 "$CACHE_FILE" +fi From c49ffb1cb77067901fbfb5f000c7c7789c1cc44d Mon Sep 17 00:00:00 2001 From: Paulo Alvares Date: Tue, 2 Jun 2026 02:46:30 +0100 Subject: [PATCH 2/3] feat: update notification mute script --- scripts/notification-mute.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/notification-mute.sh b/scripts/notification-mute.sh index 56658a3..12d112b 100755 --- a/scripts/notification-mute.sh +++ b/scripts/notification-mute.sh @@ -10,14 +10,14 @@ # Set the name, place the path to file, e.g. /home//Software/ubuntu-notification-shortcut and select the keyboard combination # Get the current state of the notificiation mode -state=$(gsettings get org.gnome.desktop.notifications show-banners) +state=$(dunstctl is-paused) -if [[ $state == 'true' ]] +if [[ $state == 'false' ]] then notify-send "Notifications: disabled"; sleep 0.3; - gsettings set org.gnome.desktop.notifications show-banners false + dunstctl set-paused true else - gsettings set org.gnome.desktop.notifications show-banners true - notify-send "Notifications: enabled" + notify-send "Notifications: enabled"; + dunstctl set-paused false fi From 1e080013ddf6c7ee5be87a9cd8424aa7134d9259 Mon Sep 17 00:00:00 2001 From: Paulo Alvares Date: Tue, 2 Jun 2026 02:58:08 +0100 Subject: [PATCH 3/3] feat: update open pr function name --- aliasfunctions/.bashgitrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliasfunctions/.bashgitrc b/aliasfunctions/.bashgitrc index 49b97c3..5ee090c 100644 --- a/aliasfunctions/.bashgitrc +++ b/aliasfunctions/.bashgitrc @@ -10,7 +10,7 @@ function dalemarcio() { fi } -function gpr-url() { +function git-pr() { local branch remote host owner repo path url branch=$(git symbolic-ref --short HEAD) || return 1