From 48469dc470dea829548973760e1af5ab3a0e1dc9 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 7 Jan 2024 11:35:20 -0500 Subject: [PATCH] ENH clean up .bin --- dot_bin/executable_autogit | 21 ---- dot_bin/executable_aw-stop | 5 - dot_bin/executable_batmon | 22 ----- dot_bin/executable_emacs-start | 5 - dot_bin/executable_emacs-stop | 5 - dot_bin/executable_gpg | 5 - dot_bin/executable_mount.veracrypt | 30 ------ dot_bin/executable_mu-index-emacs-maybe | 12 --- dot_bin/executable_pass | 5 - dot_bin/executable_pinentry-test.rb | 97 ------------------- dot_bin/executable_screencap | 22 ----- dot_bin/executable_screenlock | 61 ------------ dot_bin/executable_togglebt | 14 --- dot_bin/executable_umount-force-veracrypt | 6 ++ dot_bin/executable_umount.veracrypt | 15 --- .../bootstrap/executable_build.tmpl | 0 .../bootstrap/executable_make_pkgs.tmpl | 0 .../bootstrap/executable_mamba | 0 .../bootstrap/executable_runtime_pkgs.tmpl | 6 +- .../tmux/scripts}/executable_tmuxctl | 0 .../xdg_stubs}/executable_mbsync | 0 .../xdg_stubs}/executable_nvidia-settings | 0 .../xdg_stubs}/executable_svn | 0 .../xdg_stubs}/executable_tj3client | 0 .../xdg_stubs}/executable_tj3d | 0 .../xdg_stubs}/executable_tj3webd | 0 dot_zshenv.tmpl | 9 ++ 27 files changed, 18 insertions(+), 322 deletions(-) delete mode 100644 dot_bin/executable_autogit delete mode 100644 dot_bin/executable_aw-stop delete mode 100644 dot_bin/executable_batmon delete mode 100644 dot_bin/executable_emacs-start delete mode 100644 dot_bin/executable_emacs-stop delete mode 100644 dot_bin/executable_gpg delete mode 100644 dot_bin/executable_mount.veracrypt delete mode 100644 dot_bin/executable_mu-index-emacs-maybe delete mode 100644 dot_bin/executable_pass delete mode 100644 dot_bin/executable_pinentry-test.rb delete mode 100644 dot_bin/executable_screencap delete mode 100644 dot_bin/executable_screenlock delete mode 100644 dot_bin/executable_togglebt create mode 100644 dot_bin/executable_umount-force-veracrypt delete mode 100644 dot_bin/executable_umount.veracrypt rename dot_bin/executable_bootstrap_build.tmpl => dot_config/bootstrap/executable_build.tmpl (100%) rename dot_bin/executable_bootstrap_make_pkgs.tmpl => dot_config/bootstrap/executable_make_pkgs.tmpl (100%) rename dot_bin/executable_bootstrap_mamba => dot_config/bootstrap/executable_mamba (100%) rename dot_bin/executable_bootstrap_runtime_pkgs.tmpl => dot_config/bootstrap/executable_runtime_pkgs.tmpl (83%) rename {dot_bin => dot_config/tmux/scripts}/executable_tmuxctl (100%) rename {dot_bin => dot_config/xdg_stubs}/executable_mbsync (100%) rename {dot_bin => dot_config/xdg_stubs}/executable_nvidia-settings (100%) rename {dot_bin => dot_config/xdg_stubs}/executable_svn (100%) rename {dot_bin => dot_config/xdg_stubs}/executable_tj3client (100%) rename {dot_bin => dot_config/xdg_stubs}/executable_tj3d (100%) rename {dot_bin => dot_config/xdg_stubs}/executable_tj3webd (100%) diff --git a/dot_bin/executable_autogit b/dot_bin/executable_autogit deleted file mode 100644 index c4f23ff..0000000 --- a/dot_bin/executable_autogit +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -### Add org file changes to git repo - -for REPO in $1 -do - echo "repository: $REPO" - eval "cd $REPO" - # check for errors - if ! git fsck --strict > /dev/null 2>&1; then - notify-send "Org git commit failed." - fi - # remove deleted files - git ls-files --deleted -z | xargs -0 git rm >/dev/null 2>&1 - # add new files - git add . >/dev/null 2>&1 - git commit -m "$(date)" - # push - git push origin master -done -echo Done diff --git a/dot_bin/executable_aw-stop b/dot_bin/executable_aw-stop deleted file mode 100644 index b138bbb..0000000 --- a/dot_bin/executable_aw-stop +++ /dev/null @@ -1,5 +0,0 @@ -#! /usr/bin/env bash - -# kill all activity-watch deamons - -pkill aw- diff --git a/dot_bin/executable_batmon b/dot_bin/executable_batmon deleted file mode 100644 index 8544cde..0000000 --- a/dot_bin/executable_batmon +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/bash - -# small script to log battery usage in txt file for conky to parse -# lovingly stolen from battery-stats by petter reinholdtsen - -DST_FILE="$XDG_CACHE_HOME/batmon.log" -SYS_BAT_PATH="/sys/class/power_supply/BAT0" -BAT_CAP_PATH="$SYS_BAT_PATH/charge_now" -BAT_CAP_FULL_PATH="$SYS_BAT_PATH/charge_full" -MAX_ENTRIES=1440 # number of minutes in day - -read_bat_percent() { - timestamp=$(date +%s) - charge_now=$(cat "$BAT_CAP_PATH") - charge_full=$(cat "$BAT_CAP_FULL_PATH") - percent=$(echo "100 * $charge_now / $charge_full" | bc) - echo $timestamp $percent >> "$DST_FILE" -} - -read_bat_percent -# truncate to most recent entries by max_entries -tail -n $MAX_ENTRIES "$DST_FILE" > /tmp/batmon.tmp.log && mv /tmp/batmon.tmp.log "$DST_FILE" diff --git a/dot_bin/executable_emacs-start b/dot_bin/executable_emacs-start deleted file mode 100644 index 657968e..0000000 --- a/dot_bin/executable_emacs-start +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -# start the emacs daemon - -emacs --fg-daemon > /dev/null 2>&1 diff --git a/dot_bin/executable_emacs-stop b/dot_bin/executable_emacs-stop deleted file mode 100644 index dc7c334..0000000 --- a/dot_bin/executable_emacs-stop +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -# stop the emacs daemon - -emacsclient --eval "(kill-emacs)" diff --git a/dot_bin/executable_gpg b/dot_bin/executable_gpg deleted file mode 100644 index facaa97..0000000 --- a/dot_bin/executable_gpg +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -## gpg (override): mount GNUPGHOME before executing - -with_gpg_mount /usr/bin/gpg "$@" diff --git a/dot_bin/executable_mount.veracrypt b/dot_bin/executable_mount.veracrypt deleted file mode 100644 index 4853b86..0000000 --- a/dot_bin/executable_mount.veracrypt +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/bash - -## mount a veracrypt volume - -## NOTE this will need the DISPLAY variable in order to prompt for the bitwarden -## password -pwd=$(dbus-send --print-reply=literal --session \ - --dest=org.rofi.bitwarden \ - /bitwarden org.rofi.bitwarden.session.GetPassword \ - string:"$1" | \ - sed -e 's/^ *//g') - -## the funny evals are here to expand any literal env variables that may be -## passed because systemd didn't expand them (yuck) -volume="$(eval echo "$2")" -mountpoint="$(eval echo "$3")" - -if [[ "$pwd" == "" ]]; then - echo "Could not get bitwarden password" - exit 1 -else - if /usr/bin/sudo /usr/bin/veracrypt \ - --text --non-interactive --stdin \ - "$volume" "$mountpoint" <<< "$pwd"; then - echo "Mounted $1" - else - echo "Failed to mount $1" - exit 1 - fi -fi diff --git a/dot_bin/executable_mu-index-emacs-maybe b/dot_bin/executable_mu-index-emacs-maybe deleted file mode 100644 index 4872cb6..0000000 --- a/dot_bin/executable_mu-index-emacs-maybe +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh - -## indexes mu depending on whether emacs mu4e is running - -## assume the mu server is only started by mu4e -if pgrep -fx '/usr/bin/mu server' > /dev/null; then - echo indexing mu through emacs - emacsclient -e '(mu4e-update-index)' > /dev/null -else - echo indexing mu natively - mu index -fi diff --git a/dot_bin/executable_pass b/dot_bin/executable_pass deleted file mode 100644 index 7e81ddd..0000000 --- a/dot_bin/executable_pass +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -## pass (override): mount $GNUPGHOME before executing - -with_gpg_mount /usr/bin/pass "$@" diff --git a/dot_bin/executable_pinentry-test.rb b/dot_bin/executable_pinentry-test.rb deleted file mode 100644 index 0359e1d..0000000 --- a/dot_bin/executable_pinentry-test.rb +++ /dev/null @@ -1,97 +0,0 @@ -#! /usr/bin/env ruby -# coding: utf-8 - -# Copyright © 2016 Quentin "Sardem FF7" Glidic -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -rofi=%w( rofi -dmenu -input /dev/null -password ) - - -def assuan_send(t) - $stdout.puts t - $stdout.flush -end - -assuan_send "OK Please go ahead" -while ( line = $stdin.readline ) - ok = true - case ( line ) - when /^OPTION (.+)$/ - #OPTION grab - #OPTION ttyname=/dev/pts/1 - #OPTION ttytype=tmux-256color - #OPTION lc-messages=C - #OPTION allow-external-password-cache - #OPTION default-ok=_OK - #OPTION default-cancel=_Cancel - #OPTION default-yes=_Yes - #OPTION default-no=_No - #OPTION default-prompt=PIN: - #OPTION default-pwmngr=_Save in password manager - #OPTION default-cf-visi=Do you really want to make your passphrase visible on the screen? - #OPTION default-tt-visi=Make passphrase visible - #OPTION default-tt-hide=Hide passphrase - #OPTION touch-file=/run/user/1000/gnupg/S.gpg-agent - when /^GETINFO (.+)$/ - info = $1 - case ( info ) - when 'pid' - assuan_send "D #{Process.pid}" - end - when /^SETKEYINFO (.+)$/ - #SETKEYINFO s/FINGERPRINT - when /^SETDESC (.+)$/ - print "hi\n" - #SETDESC Please enter the passphrase for the ssh key%0A ke:yf:in:ge:rp:ri:nt - rofi << '-mesg' << $1.gsub('<', '<').gsub(/%([0-9A-Fa-f]{2})/) { $1.to_i(16).chr } - when /^SETPROMPT (.+)$/ - #SETPROMPT Passphrase: - rofi << '-p' << $1 - when /^GETPIN$/ - pass = nil - IO.popen(%w( systemctl --user show-environment )) do |io| - until ( io.eof? ) - var = io.readline - var.match(/^([A-Za-z_]+)=(.+)$/) - var, val = $~[1..2] - ENV[var] = val - end - end - err_in, err_out = IO.pipe - IO.popen([*rofi, :err => err_out]) do |io| - pass = io.read - end - status = $? - err_out.close - case ( status.exitstatus ) - when 0 - assuan_send "D #{pass}" unless ( pass.empty? ) - when 1 - assuan_send "ERR 83886179 Operation cancelled " - ok = false - end - when /^BYE(?= |$)/ - exit(0) - else - assuan_send "BYE" - exit(1) - end - assuan_send "OK" if ( ok ) -end diff --git a/dot_bin/executable_screencap b/dot_bin/executable_screencap deleted file mode 100644 index fe1aa4c..0000000 --- a/dot_bin/executable_screencap +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/bash - -## capture a screenshot using scrot - -SS_DIR="$XDG_CACHE_HOME/screenshots" - -while getopts ":sw" opt; do - case ${opt} in - s) - scrot "$SS_DIR/desktop/%Y-%m-%d-%H:%M:%S_desktop.png" - notify-send "Screen captured" - ;; - w) - scrot -u "$SS_DIR/window/%Y-%m-%d-%H:%M:%S-\$wx\$h.png" - notify-send "Window captured" - ;; - \?) - echo "invalid option, read the code" - ;; - esac -done - diff --git a/dot_bin/executable_screenlock b/dot_bin/executable_screenlock deleted file mode 100644 index a98af77..0000000 --- a/dot_bin/executable_screenlock +++ /dev/null @@ -1,61 +0,0 @@ -#! /bin/bash - -## lock the screen using i3lock (and maybe suspend) - -## usage: screenlock [SUSPEND] - -# WORKAROUND make the date show up in the right place on 2+ monitor setups -# I want it to only show up on the primary screen, so use xrandr to get the -# dimensions and position of the primary monitor and calculate the date position -# from that -geometry=$(xrandr | sed -n 's/^.*primary \([0-9]*\)x[0-9]*+\([0-9]\)*+[0-9]* .*/\1 \2/p') -width=$(echo "$geometry" | cut -f1 -d" ") -xpos=$(echo "$geometry" | cut -f2 -d" ") -xoffset=$(("$xpos" + "$width" / 2)) -datepos="$xoffset:600" - -# lock and fork so we can suspend with the screen locked -i3lock --color=000000 \ - --pass-media-keys \ - --nofork \ - --ignore-empty-password \ - --screen=0 \ - --indicator \ - --inside-color=00000055 \ - --insidever-color=00000055 \ - --insidewrong-color=00000055 \ - --ring-color=555555ff \ - --ringwrong-color=ff3333ff \ - --ringver-color=99ceffff \ - --keyhl-color=99ceffff \ - --bshl-color=9523ffff \ - --line-color=00000000 \ - --separator-color=00000000 \ - --clock \ - --verif-color=99ceffff \ - --wrong-color=ff8282ff \ - --time-color=ffffffff \ - --time-size=72 \ - --time-str="%H:%M" \ - --date-color=ffffffff \ - --date-size=42 \ - --date-str="%b %d, %Y" \ - --date-align 0 \ - --date-pos="$datepos" \ - --wrong-size=72 \ - --verif-size=72 \ - --radius=300 \ - --ring-width=25 & - -# suspend if we want, and if this machine is currently using a battery -batpath=/sys/class/power_supply/BAT0/status - -if [ -f "$batpath" ] && \ - [ "$(cat $batpath)" == "Discharging" ] && \ - [ "$1" == "true" ]; then - systemctl suspend -fi - -# block until the screen is unlocked (since xss-lock expects the locker to exit -# only when unlocked) -wait diff --git a/dot_bin/executable_togglebt b/dot_bin/executable_togglebt deleted file mode 100644 index 8a3e909..0000000 --- a/dot_bin/executable_togglebt +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/bash - -## toggle the bluetooth power state and notify - -## lazy awk usage :) -btstate="$(bluetoothctl show | grep "Powered: " | awk '{print $2}')" - -btaction="off" -if [[ $btstate == "no" ]]; then - btaction="on" -fi - -bluetoothctl power "$btaction" > /dev/null -notify-send "bluetooth powered $btaction" diff --git a/dot_bin/executable_umount-force-veracrypt b/dot_bin/executable_umount-force-veracrypt new file mode 100644 index 0000000..8d99f5b --- /dev/null +++ b/dot_bin/executable_umount-force-veracrypt @@ -0,0 +1,6 @@ +#! /usr/bin/env bash + +umount "/dev/mapper/veracrypt$1" +dmsetup remove "veracrypt$1" +dmsetup remove "veracrypt$1_0" +dmsetup remove "veracrypt$1_1" diff --git a/dot_bin/executable_umount.veracrypt b/dot_bin/executable_umount.veracrypt deleted file mode 100644 index be19f50..0000000 --- a/dot_bin/executable_umount.veracrypt +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/bash - -## unmount a veracrypt volume - - -## the funny evals are here to expand any literal env variables that may be -## passed because systemd didn't expand them (yuck) -mountpoint="$(eval echo "$1")" - -if /usr/bin/sudo /usr/bin/veracrypt -d "$mountpoint"; then - echo "Unmounted $1" -else - echo "Failed to unmount $1" - exit 1 -fi diff --git a/dot_bin/executable_bootstrap_build.tmpl b/dot_config/bootstrap/executable_build.tmpl similarity index 100% rename from dot_bin/executable_bootstrap_build.tmpl rename to dot_config/bootstrap/executable_build.tmpl diff --git a/dot_bin/executable_bootstrap_make_pkgs.tmpl b/dot_config/bootstrap/executable_make_pkgs.tmpl similarity index 100% rename from dot_bin/executable_bootstrap_make_pkgs.tmpl rename to dot_config/bootstrap/executable_make_pkgs.tmpl diff --git a/dot_bin/executable_bootstrap_mamba b/dot_config/bootstrap/executable_mamba similarity index 100% rename from dot_bin/executable_bootstrap_mamba rename to dot_config/bootstrap/executable_mamba diff --git a/dot_bin/executable_bootstrap_runtime_pkgs.tmpl b/dot_config/bootstrap/executable_runtime_pkgs.tmpl similarity index 83% rename from dot_bin/executable_bootstrap_runtime_pkgs.tmpl rename to dot_config/bootstrap/executable_runtime_pkgs.tmpl index 1c2693a..aa04ff3 100644 --- a/dot_bin/executable_bootstrap_runtime_pkgs.tmpl +++ b/dot_config/bootstrap/executable_runtime_pkgs.tmpl @@ -13,7 +13,7 @@ list_rofi_pkgs() { {{ if .features.vpn -}} args+=(--expressvpn) {{- end }} - "$conf_dir/rofi-extras/scripts/runtime_pkgs" "${args[@]}" + "$conf_dir/rofi-extras/runtime_pkgs" "${args[@]}" } # notifications @@ -37,7 +37,7 @@ pkgs+=(rxvt-unicode urxvt-perls) pkgs+=(zsh zsh-completions xclip) # xmonad -mapfile -t xmonad < <("$conf_dir/xmonad/scripts/runtime_pkgs") +mapfile -t xmonad < <("$conf_dir/xmonad/runtime_pkgs") pkgs=("${pkgs[@]}" "${xmonad[@]}") # rofi extras @@ -48,7 +48,7 @@ pkgs=("${pkgs[@]}" "${rofix[@]}") pkgs+=(xcape) {{- if .development.emacs }} -mapfile -t emacs < <("$conf_dir/xmonad/scripts/runtime_pkgs") +mapfile -t emacs < <("$conf_dir/emacs/runtime_pkgs") pkgs=("${pkgs[@]}" "${emacs[@]}") {{- end }} diff --git a/dot_bin/executable_tmuxctl b/dot_config/tmux/scripts/executable_tmuxctl similarity index 100% rename from dot_bin/executable_tmuxctl rename to dot_config/tmux/scripts/executable_tmuxctl diff --git a/dot_bin/executable_mbsync b/dot_config/xdg_stubs/executable_mbsync similarity index 100% rename from dot_bin/executable_mbsync rename to dot_config/xdg_stubs/executable_mbsync diff --git a/dot_bin/executable_nvidia-settings b/dot_config/xdg_stubs/executable_nvidia-settings similarity index 100% rename from dot_bin/executable_nvidia-settings rename to dot_config/xdg_stubs/executable_nvidia-settings diff --git a/dot_bin/executable_svn b/dot_config/xdg_stubs/executable_svn similarity index 100% rename from dot_bin/executable_svn rename to dot_config/xdg_stubs/executable_svn diff --git a/dot_bin/executable_tj3client b/dot_config/xdg_stubs/executable_tj3client similarity index 100% rename from dot_bin/executable_tj3client rename to dot_config/xdg_stubs/executable_tj3client diff --git a/dot_bin/executable_tj3d b/dot_config/xdg_stubs/executable_tj3d similarity index 100% rename from dot_bin/executable_tj3d rename to dot_config/xdg_stubs/executable_tj3d diff --git a/dot_bin/executable_tj3webd b/dot_config/xdg_stubs/executable_tj3webd similarity index 100% rename from dot_bin/executable_tj3webd rename to dot_config/xdg_stubs/executable_tj3webd diff --git a/dot_zshenv.tmpl b/dot_zshenv.tmpl index 30cce18..279f39a 100644 --- a/dot_zshenv.tmpl +++ b/dot_zshenv.tmpl @@ -9,6 +9,9 @@ export XDG_CACHE_HOME={{ .paths.cache }} export XDG_DATA_HOME={{ .paths.data }} export XDG_RUNTIME_DIR={{ .paths.runtime }} +# xdg override directory (for calling executables that don't conform by default) +export PATH=$XDG_CONFIG_HOME/xdg_stubs:$PATH + # super common tools export PAGER=less export INPUTRC=$XDG_CONFIG_HOME/readline/inputrc @@ -53,6 +56,7 @@ export ANSIBLE_VAULT_IDENTITY=ansible/vault {{ if .development.emacs -}} # emacs +export PATH=$XDG_CONFIG_HOME/emacs/bin:$PATH export MU_HOME=$XDG_CACHE_HOME/mu export MAILDIR=/mnt/data/Mail export ASPELL_CONF="per-conf $XDG_CONFIG_HOME/aspell/aspell.conf; personal $XDG_CONFIG_HOME/aspell/en.pws; repl $XDG_CONFIG_HOME/aspell/en.prepl" @@ -138,10 +142,15 @@ export SAL_USE_VCLPLUGIN=gtk # store passwords in gnupg directory (which is then encrypted) export PASSWORD_STORE_DIR=$GNUPGHOME/pass +# tmux +export PATH=$XDG_CONFIG_HOME/tmux/scripts:$PATH + # X11 export XINITRC=$XDG_CONFIG_HOME/X11/xinitrc # xmonad (and haskell) +export PATH=$XDG_CONFIG_HOME/xmonad/scripts:$PATH +export PATH=$XDG_CONFIG_HOME/rofi-extras/scripts:$PATH export STACK_ROOT=$XDG_DATA_HOME/stack export XMONAD_CACHE_DIR=$XDG_CACHE_HOME/xmonad export XMONAD_CONFIG_DIR=$XDG_CONFIG_HOME/xmonad