ENH clean up .bin

This commit is contained in:
Nathan Dwarshuis 2024-01-07 11:35:20 -05:00
parent b306fe9bc9
commit 48469dc470
27 changed files with 18 additions and 322 deletions

View File

@ -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

View File

@ -1,5 +0,0 @@
#! /usr/bin/env bash
# kill all activity-watch deamons
pkill aw-

View File

@ -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"

View File

@ -1,5 +0,0 @@
#! /bin/bash
# start the emacs daemon
emacs --fg-daemon > /dev/null 2>&1

View File

@ -1,5 +0,0 @@
#! /bin/bash
# stop the emacs daemon
emacsclient --eval "(kill-emacs)"

View File

@ -1,5 +0,0 @@
#! /bin/bash
## gpg (override): mount GNUPGHOME before executing
with_gpg_mount /usr/bin/gpg "$@"

View File

@ -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

View File

@ -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

View File

@ -1,5 +0,0 @@
#! /bin/bash
## pass (override): mount $GNUPGHOME before executing
with_gpg_mount /usr/bin/pass "$@"

View File

@ -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('<', '&lt;').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 <rofi>"
ok = false
end
when /^BYE(?= |$)/
exit(0)
else
assuan_send "BYE"
exit(1)
end
assuan_send "OK" if ( ok )
end

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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 }}

View File

@ -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