diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile.m4 | 11 | ||||
-rw-r--r-- | bin/pingme.m4 | 15 | ||||
-rwxr-xr-x | bin/sqlwait | 113 | ||||
-rwxr-xr-x | bin/toggle-theme | 21 | ||||
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | linux/tmux.conf.m4 | 93 |
7 files changed, 197 insertions, 78 deletions
@@ -97,3 +97,5 @@ Common/newsboat/cache.db Common/newsboat/cache.db.lock Common/newsboat/history.cmdline Common/newsboat/urls + +bin/pingme diff --git a/Makefile.m4 b/Makefile.m4 index ee3255d..0f2ae6e 100644 --- a/Makefile.m4 +++ b/Makefile.m4 @@ -26,7 +26,7 @@ define create_dotfile_symlink $(call create_symlink,${SRC_DIR}/$(1),${HOME_DIR}/$(2)) endef -all: system.m4 install_packages install_cargo_packages m4_dnl +all: system.m4 install_packages m4_dnl m4_ifelse(DT_VIM, `yes', `$(HOME_DIR)/.vimrc') m4_dnl m4_ifelse(DT_VIM, `yes', `$(HOME_DIR)/.vim') m4_dnl m4_ifelse(DT_ROFI, `yes', `$(HOME_DIR)/.config/rofi') m4_dnl @@ -107,9 +107,16 @@ $(HOME_DIR)/.config/bspwm: linux/bspwm ')m4_dnl m4_ifelse(DT_HOMEBIN, `yes', `m4_dnl -$(HOME_DIR)/bin: bin +M4_BINFILES := $(patsubst bin/%.m4,bin/%,$(wildcard bin/*.m4)) + +$(HOME_DIR)/bin: bin ${M4_BINFILES} $(call create_dotfile_symlink,bin,bin) +bin/%: bin/%.m4 \ + ${M4_COMMON_DEPS} + $(call M4_EXEC) + chmod +x $@ + ')m4_dnl m4_ifelse(DT_BASH, `yes', `m4_dnl Common/bashrc: Common/bashrc.m4 \ diff --git a/bin/pingme.m4 b/bin/pingme.m4 new file mode 100644 index 0000000..5eea292 --- /dev/null +++ b/bin/pingme.m4 @@ -0,0 +1,15 @@ +#!/bin/sh +set -e +m4_ifelse(DT_GOTIFY_URL, `', `', `m4_dnl +GOTIFY_URL="DT_GOTIFY_URL/message?token=DT_GOTIFY_TOKEN" +')m4_dnl +MESSAGE="Done" +if [ "$#" = "1" ]; then + MESSAGE="$1" +fi + +tput bel +tmux display-message "${MESSAGE}" +m4_ifelse(DT_GOTIFY_URL, `', `', `m4_dnl +GOTIFY_RES=$(curl "$GOTIFY_URL" -F "title=Pingme" -F "message=$MESSAGE" -F "priority=5" 2> /dev/null) +')m4_dnl diff --git a/bin/sqlwait b/bin/sqlwait new file mode 100755 index 0000000..6ba406e --- /dev/null +++ b/bin/sqlwait @@ -0,0 +1,113 @@ +#!/bin/sh +set -e + +PRINT_FLAG=false +MYSQL_HOST="localhost" +COMPARE_TYPE="eq" + +usage() { + printf "$0 [options] <query> <target>\n" + printf "\t-H <host>\tMysql host\n" + printf "\t-u <user>\tMysql user\n" + printf "\t-d <database>\tMysql database\n" + printf "\t-c <compare_typw>\teq, lt or gt, defaults to eq\n" + printf "\t-p\t\tPrint the current value for each check\n" +} + + +while getopts "H:u:d:c:p" opt; do + case ${opt} in + H ) + MYSQL_HOST="$OPTARG" + ;; + u ) + MYSQL_USER="$OPTARG" + ;; + d ) + MYSQL_DATABASE="$OPTARG" + ;; + c ) + COMPARE_TYPE="$OPTARG" + ;; + p ) + PRINT_FLAG=true + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + exit 1 + ;; + : ) + echo "Option -$OPTARG requires an argument." 1>&2 + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +if [ -z "$1" ]; then + echo "Error: <query> argument is missing." >&2 + usage + exit 1 +fi +QUERY="$1" + +if [ -z "$2" ]; then + echo "Error: <target> argument is missing." >&2 + usage + exit 1 +fi +TARGET="$2" + +if [ -z "$MYSQL_HOST" ]; then + echo "Error: -H <host> argument is missing." >&2 + usage + exit 1 +fi + +if [ -z "$MYSQL_USER" ]; then + echo "Error: -u <user> argument is missing." >&2 + usage + exit 1 +fi + +if [ -z "$MYSQL_DATABASE" ]; then + echo "Error: -d <database> argument is missing." >&2 + usage + exit 1 +fi + +read -s -p "Enter password: " MYSQL_PASSWORD +echo + +while true; do + RESULT=$(mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -h"$MYSQL_HOST" "$MYSQL_DATABASE" -e "$QUERY" --batch --silent 2> /dev/null) + if [ "$PRINT_FLAG" = true ]; then + echo "[$(date)]: ${RESULT}" + fi + + if [ "$COMPARE_TYPE" = "eq" ]; then + if [ "$RESULT" = "$$TARGET" ]; then + if [ "$PRINT_FLAG" = true ]; then + echo "[$(date)]: Target reached $RESULT = $TARGET" + fi + break + fi + elif [ "$COMPARE_TYPE" = "lt" ]; then + if (( RESULT < TARGET )); then + if [ "$PRINT_FLAG" = true ]; then + echo "[$(date)]: Target reached $RESULT < $TARGET" + fi + break + fi + elif [ "$COMPARE_TYPE" = "gt" ]; then + if (( RESULT > TARGET )); then + if [ "$PRINT_FLAG" = true ]; then + echo "[$(date)]: Target reached $RESULT > $TARGET" + fi + break + fi + fi + + sleep 10 +done + diff --git a/bin/toggle-theme b/bin/toggle-theme index aa3c626..8fe1547 100755 --- a/bin/toggle-theme +++ b/bin/toggle-theme @@ -27,14 +27,8 @@ if [ "$THEME" = "dark" ]; then # Update tmux (Consider making a theme switch in the m4 config and re-running that instead of having it configured here) tmux set-environment THEME "light" tmux set-environment ALACRITTY_THEME "${LIGHTTHEME}" - tmux set -g status-bg "#F2EEDE" - tmux set -g status-fg colour15 - tmux setw -g window-status-current-style "bg=colour0,fg=colour255" - tmux setw -g window-status-style "bg=colour7,fg=colour0" - tmux setw -g window-status-bell-style "bg=colour23,fg=colour255" - tmux setw -g window-status-activity-style "bg=colour243,fg=colour255" - tmux set -g status-left "#[fg=colour232,bg=colour3,bold]#{?client_prefix,C-a,}#[default] #[fg=colour0,bg=colour7,bold][#S]#[default] " - tmux set -g status-right "#[fg=colour0,bg=colour7,bold] #(hostname) #[default] #[fg=colour0,bg=colour7,bold] %d/%m/%y #[default] #[fg=colour0,bg=colour7,bold] %H:%M:%S #[default] #[bg=colour7,fg=colour0,bold] #(cat /sys/class/power_supply/BAT0/capacity)% #[default] " + tmux set -g status-bg black + tmux set -g status-fg colour255 # Update nvim send_vim_cmd ":set background=light" @@ -49,15 +43,8 @@ else # Update tmux tmux set-environment THEME "dark" tmux set-environment ALACRITTY_THEME "${DARKTHEME}" - tmux set -g status-bg "#0c0c0c" - tmux set -g status-fg "#d6d6d6" - tmux setw -g window-status-style "bg=colour235,fg=colour7" - tmux setw -g window-status-current-style "bg=colour237,fg=colour7" - tmux setw -g window-status-bell-style "bg=colour23,fg=colour15" - tmux setw -g window-status-activity-style "bg=colour239,fg=colour15" - tmux set -g status-left "#[fg=colour232,bg=colour3,bold]#{?client_prefix,C-a,}#[default] #[fg=colour7,bg=colour235,bold][#S]#[default] " - tmux set -g status-right "#[fg=colour7,bg=colour235,bold] #(hostname) #[default] #[fg=colour7,bg=colour235,bold] %d/%m/%y #[default] #[fg=colour7,bg=colour235,bold] %H:%M:%S #[default] #[bg=colour235,fg=colour7,bold] #(cat /sys/class/power_supply/BAT0/capacity)% #[default] " - sed -i 's/"dark"/"light"/' "${VIMCONF}" + tmux set -g status-bg white + tmux set -g status-fg black # Update nvim send_vim_cmd ":set background=dark" @@ -44,6 +44,8 @@ fi : "${DT_QTILE:=no}" : "${DT_BASH:=yes}" : "${DT_HOMEBIN:=no}" +: "${DT_GOTIFY_URL:=}" +: "${DT_GOTIFY_TOKEN:=}" : "${DT_TMUX:=yes}" : "${DT_HELIX:=no}" : "${DT_MYCLI:=no}" @@ -261,12 +263,28 @@ if [ "${DT_NEWSBOAT}" = "yes" ]; then "Url:" 1 1 "${DT_NEWSBOAT_SOURCE:-}" 1 10 255 0 \ "Username:" 2 1 "${DT_NEWSBOAT_USER:-}" 2 10 255 0 \ 3>&1 1>&2 2>&3 3>&-) - NEWSBOAT_VALUES=($NEWSBOAT_VALUES) if [ "$?" -eq 1 ]; then exit 0; fi + NEWSBOAT_VALUES=($NEWSBOAT_VALUES) DT_NEWSBOAT_SOURCE=${NEWSBOAT_VALUES[0]} DT_NEWSBOAT_USER=${NEWSBOAT_VALUES[1]} fi +if [ "${DT_HOMEBIN}" = "yes" ]; then + GOTIFY_VALUES=$(dialog \ + --keep-tite \ + --backtitle "Dotfile configuration" \ + --title "Configure" \ + --form "Gotify (push) settings" \ + 0 50 0 \ + "Url:" 1 1 "${DT_GOTIFY_URL:-}" 1 10 255 0 \ + "Push token:" 2 1 "${DT_GOTIFY_TOKEN:-}" 2 10 255 0 \ + 3>&1 1>&2 2>&3 3>&-) + if [ "$?" -eq 1 ]; then exit 0; fi + GOTIFY_VALUES=($GOTIFY_VALUES) + DT_GOTIFY_URL=${GOTIFY_VALUES[0]} + DT_GOTIFY_TOKEN=${GOTIFY_VALUES[1]} +fi + # write config to file printf "" > "${CONFIG_FILE}" set | grep '^DT_' | awk -F '=' '{print $1"="$2""}' >> "${CONFIG_FILE}" diff --git a/linux/tmux.conf.m4 b/linux/tmux.conf.m4 index 1e7322a..23c5418 100644 --- a/linux/tmux.conf.m4 +++ b/linux/tmux.conf.m4 @@ -1,26 +1,14 @@ # -- general ------------------------------------------------------------------- -#set -g default-terminal "xterm-256color" set -g default-terminal "tmux-256color" set-option -ga terminal-overrides ",xterm-256color:Tc" # don't remember set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colours - needs tmux-3.0 -set -s escape-time 0 # faster command sequences -set -s focus-events on - -# -- display ------------------------------------------------------------------- -set -g base-index 1 -setw -g pane-base-index 1 -setw -g automatic-rename on # rename window to reflect current program -set -g renumber-windows on # renumber windows when a window is closed - -set -g display-panes-time 800 # slightly longer pane indicators display time -set -g display-time 1000 # slightly longer status messages display time - -set -g status-interval 10 # redraw status linebg every 10 seconds -set-option -g history-limit 5000 - +set -s escape-time 0 # faster command sequences, vim is really annoying without it +setw -g automatic-rename on +set-option -g history-limit 10000 set-option -g default-shell DT_SHELL +set -s focus-events on # -- navigation ---------------------------------------------------------------- @@ -28,6 +16,10 @@ set-option -g default-shell DT_SHELL setw -g monitor-activity on set -g visual-activity off +# Bells +set -g visual-bell on +set -g bell-action any + m4_ifelse(DT_DOTFILES_TYPE, `local', `m4_dnl unbind C-b set -g prefix C-a @@ -43,21 +35,35 @@ bind-key -T copy-mode-vi 'r' send -X rectangle-toggle bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel 'xclip -sel clip -i' unbind -T copy-mode-vi Enter bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -se c -i' -bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -se c -ind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -se c -i' -bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -se c -i'' -# Bells -set -g visual-bell on -set -g bell-action any +# -- macros -------------------------------------------------------------------- +# Set tmux style on remote +bind-key C-r send-keys C-b ":set status-style 'fg=black,bg=purple'" -# Sync panes +# Synchronize panes bind-key = set-window-option synchronize-panes -# -- macros -------------------------------------------------------------------- +# Reload +bind-key r source-file ~/.tmux.conf + +# Git author bind-key s send-keys "DT_GIT_USER <DT_GIT_EMAIL>" -bind-key C-r send-keys C-b ":set status-style 'fg=black,bg=purple'" +# Quick notes, diary +bind -n M-w display-popup -E "nvim -c VimwikiIndex -c Calendar -c 'wincmd p'" +bind -n M-C-w display-popup -E "nvim -c VimwikiMakeDiaryNote -c Calendar -c 'wincmd p' -c 'call append(1, strftime(\"- **%T** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" +bind -n M-C-i display-popup -E "nvim -c 'e ~/Nextcloud/wiki/I45/Hendelser.md' -c 'call append(1, strftime(\"- **%d.%m.%Y (%T)** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" +# Theme toggling +bind-key T run-shell "toggle-theme" +m4_changequote({, })m4_dnl +m4_ifelse(DT_DOTFILES_TYPE, {local}, {m4_dnl +set-hook -g session-window-changed 'run-shell "update-theme"' +set-hook -g window-renamed 'run-shell "update-theme"' +bind-key C-p run-shell "tmux display-message -p '#W' | grep -q '^PROD' || tmux rename-window 'PROD #{window_name}'" +bind-key C-s run-shell "tmux display-message -p '#W' | grep -q '^STAGING' || tmux rename-window 'STAGING #{window_name}'" +})m4_dnl +m4_changequote(`, ')m4_dnl m4_changequote({, })m4_dnl m4_ifelse(DT_TMUX_NAVIGATOR, `yes', { # -- vim-tmux-navigator -------------------------------------------------------- @@ -84,49 +90,20 @@ bind-key -T copy-mode-vi 'C-\' select-pane -l })m4_dnl m4_changequote(`, ')m4_dnl -# -- Utility ------------------------------------------------------------------ -bind-key r source-file ~/.tmux.conf - -bind -n M-w display-popup -E "nvim -c VimwikiIndex -c Calendar -c 'wincmd p'" -bind -n M-C-w display-popup -E "nvim -c VimwikiMakeDiaryNote -c Calendar -c 'wincmd p' -c 'call append(1, strftime(\"- **%T** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" -bind -n M-C-i display-popup -E "nvim -c 'e ~/Nextcloud/wiki/I45/Hendelser.md' -c 'call append(1, strftime(\"- **%d.%m.%Y (%T)** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" - -bind-key T run-shell "toggle-theme" - -m4_changequote({, })m4_dnl -m4_ifelse(DT_DOTFILES_TYPE, {local}, { -set-hook -g session-window-changed 'run-shell "update-theme"' -set-hook -g window-renamed 'run-shell "update-theme"' -bind-key C-p run-shell "tmux display-message -p '#W' | grep -q '^PROD' || tmux rename-window 'PROD #{window_name}'" -bind-key C-S run-shell "tmux display-message -p '#W' | grep -q '^STAGING' || tmux rename-window 'STAGING #{window_name}'" -})m4_dnl -m4_changequote(`, ')m4_dnl - # -- Theme -------------------------------------------------------------------- m4_ifelse(DT_DOTFILES_TYPE, `local', `m4_dnl set -g status-justify left set -g status-interval 2 set -g status-position bottom -#set -g status-bg "#f8f8f8" -set -g status-bg "#F2EEDE" -set -g status-fg colour16 - -set -g status-left "#[fg=colour232,bg=colour3,bold]#{?client_prefix,C-a,}#[default] #[fg=colour0,bg=colour7,bold][#S]#[default] " -set -g status-left-length 20 - -set -g status-right "#[fg=colour0,bg=colour7,bold] #(hostname) #[default] #[fg=colour0,bg=colour7,bold] %d/%m/%y #[default] #[fg=colour0,bg=colour7,bold] %H:%M:%S #[default] #[bg=colour7,bold] #(cat /sys/class/power_supply/BAT0/capacity)% #[default] " -set -g status-right-length 50 -setw -g window-status-format " #I:#W#F " -setw -g window-status-current-format " #I:#W#F " +set -g status-left "#{?client_prefix,C-a ,}[#S] " +set -g status-right "%d/%m/%y %H:%M:%S [#(cat /sys/class/power_supply/BAT0/capacity)%]" -setw -g window-status-current-style "bg=colour0,fg=colour15" -setw -g window-status-style "bg=colour7,fg=colour0" -setw -g window-status-bell-style "bg=colour23,fg=colour15" -#setw -g window-status-activity-style "bg=colour23,fg=colour15" -setw -g window-status-activity-style "bg=colour243,fg=colour15" +set -g status-bg black +set -g status-fg colour255 ')m4_dnl m4_ifelse(DT_DOTFILES_TYPE, `remote', `m4_dnl +set -g status-left "#{?client_prefix,C-b ,}[#S] " set -g status-bg "purple" set -g status-fg "white" ')m4_dnl |