summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-06-19 10:54:56 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-06-19 11:01:13 +0200
commited7774292c866eb1ca5be8c8b022e06ece900993 (patch)
tree665bd2669f35c2b68193fc6a427e8e9bcab8ae8f
parentfc14e568f0e412e2eb6261bda8ef37843168d8e7 (diff)
downloaddotfiles-ed7774292c866eb1ca5be8c8b022e06ece900993.tar.gz
dotfiles-ed7774292c866eb1ca5be8c8b022e06ece900993.zip
misc: make notes launcher more robustHEADkde
- better error management - better logging logic
-rwxr-xr-x.local/bin/dotfiles10
-rwxr-xr-x.local/bin/notes61
2 files changed, 54 insertions, 17 deletions
diff --git a/.local/bin/dotfiles b/.local/bin/dotfiles
index b42e5d3..1d49910 100755
--- a/.local/bin/dotfiles
+++ b/.local/bin/dotfiles
@@ -5,11 +5,11 @@ declare NVIM_SRC_DIR="$HOME/.local/share/dotfiles/deps/neovim"
declare NVIM_BUILD_DIR="$HOME/.local/share/nvim"
declare -a PACKAGES_YAY=(7zip atool base-devel bash bash-completion
bash-language-server bat browserpass browserpass-firefox bzip2 cmake cpio
- ctags docker docker-buildx fd firefox foot fzf git glib2 gzip keyd lhasa
- lua-language-server lzop marksman ninja pass pigz python-black ranger
- ripgrep shfmt stylua tar texinfo tig tk tmux tree-sitter-cli unrar unzip
- vim-language-server wireshark-qt wl-clipboard xz yay zathura
- zathura-pdf-mupdf zip)
+ ctags docker docker-buildx expac fd firefox foot fzf git glib2 gzip keyd
+ lhasa libnotify lua-language-server lzop marksman ninja pass pigz
+ python-black ranger ripgrep shfmt stylua tar texinfo tig tk tmux
+ tree-sitter-cli unrar unzip util-linux vim-language-server wireshark-qt
+ wl-clipboard xz yay zathura zathura-pdf-mupdf zip)
declare -A PACKAGES_PYTHON=(
["basedpyright"]=""
["mdformat"]="mdformat-gfm,mdformat-frontmatter,mdformat-wikilink"
diff --git a/.local/bin/notes b/.local/bin/notes
index aa34960..72c4b5d 100755
--- a/.local/bin/notes
+++ b/.local/bin/notes
@@ -1,17 +1,54 @@
#!/usr/bin/bash
-set -euo pipefail
+set -Eeuo pipefail
-APP_NAME=notes
+_srealpath() {
+ local path=$1
+ realpath "$path" 2>/dev/null && return
+ printf '%s\n' "$path"
+}
+
+_err_handler() {
+ local status=$?
+ local cmd=$BASH_COMMAND
+ local line=${BASH_LINENO[0]}
+ local err_log err_msg
+ local temp
+
+ err_log=$({
+ printf "error: command failed\n\n"
+ printf '\t%-10s: %s\n' \
+ "at" "$(_srealpath "${BASH_SOURCE[1]}"):$line" \
+ "command" "$cmd" \
+ "status" "$status"
+ printf '\nstack:\n\n'
+ local i
+ for ((i = 1; i < ${#FUNCNAME[@]}; ++i)); do
+ printf '\t%s at %s:%s\n' \
+ "${FUNCNAME[i]}" \
+ "$(_srealpath "${BASH_SOURCE[i]}")" \
+ "${BASH_LINENO[$((i - 1))]}"
+ done
+ })
+ if temp=$(mktemp --suffix .log /tmp/notes.XXXXXXXXXX) &&
+ printf '%s\n' "$err_log" >"$temp"; then
+ err_msg="Log saved to $temp"
+ else
+ err_msg="Could not create temp file for log"
+ fi
+ notify-send --expire-time 0 "Failed to open notes" "$err_msg"
+}
+
+trap _err_handler ERR
+
+################################################################################
-# Log with notify-send and exit 1
-err() {
- notify-send --app-name="$APP_NAME" --icon="accessories-text-editor" \
- "Neovim notes plugin" "$NOTES_DIR does not exist or is not a directory"
- exit 1
+main() {
+ local app_name=notes
+ [[ -d $NOTES_DIR ]]
+ cd "$NOTES_DIR"
+ exec foot --title "$app_name" -- \
+ tmux new-session -A -D -s "$app_name" -- \
+ nvim +NotesFindTags
}
-[[ -d $NOTES_DIR ]] || err
-cd "$NOTES_DIR"
-exec foot -- \
- tmux new-session -A -D -s "$APP_NAME" -- \
- nvim -c "NotesFindTags"
+if [[ ${BASH_SOURCE[0]} == "$0" ]]; then main; fi