diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-11-23 23:35:59 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-11-24 12:42:27 -0700 |
commit | c67d4836f4d6d5e6c8ef4e2de38bd21ccb6ee1a1 (patch) | |
tree | fded906652b6bf03c60e0c133a368c5027cd4d1e /bin | |
parent | aa5a315a0876431105f73da75de9ddfa89e907d3 (diff) | |
download | dotfiles-c67d4836f4d6d5e6c8ef4e2de38bd21ccb6ee1a1.tar.gz |
tidy and simplify shell init
Rely on SPWCRONTAB property to set PATH for cronjobs, and otherwise rely on
.profile, .xsessionrc etc. to set PATH, once, at login. Just archive scripts
I haven't used lately which might otherwise need more significant adjustments,
or appear to be broken in other ways.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bedtime | 17 | ||||
-rwxr-xr-x | bin/debian-ftp-master | 158 | ||||
-rwxr-xr-x | bin/develacc-please | 39 | ||||
-rwxr-xr-x | bin/develacc-second-stage | 26 | ||||
-rwxr-xr-x | bin/emacsclient | 2 | ||||
-rwxr-xr-x | bin/get-sdf-mail | 2 | ||||
-rwxr-xr-x | bin/git-develacc | 2 | ||||
-rwxr-xr-x | bin/git-dotfiles-rebase | 2 | ||||
-rwxr-xr-x | bin/git-dotfiles-update-master | 2 | ||||
-rwxr-xr-x | bin/i3-startup-always | 2 | ||||
-rwxr-xr-x | bin/insinuate-dotfiles | 14 | ||||
-rwxr-xr-x | bin/logall | 1 | ||||
-rwxr-xr-x | bin/rt | 25 | ||||
-rwxr-xr-x | bin/ssh-and-tmux | 2 | ||||
-rwxr-xr-x | bin/usbskelhere | 25 | ||||
-rwxr-xr-x | bin/workstation-duplicity | 2 |
16 files changed, 8 insertions, 313 deletions
diff --git a/bin/bedtime b/bin/bedtime deleted file mode 100755 index d0fda52f..00000000 --- a/bin/bedtime +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -. $HOME/.shenv - -# someday, make this work instead: -# <http://joeyh.name/blog/entry/a_programmable_alarm_clock_using_systemd/> - -(($EUID == 0)) || exec sudo "$0" "$@" - -WHEN="${1:-tomorrow 6am}" -CMD="/home/spwhitton/bin/goodmorning" - -when=$(date +%s -d "$WHEN") - -loginctl lock-sessions -systemd-inhibit --what=handle-lid-switch --why=goodmorning sh -c \ - "rtcwake -m mem -t $when && /bin/su spwhitton -c $CMD" diff --git a/bin/debian-ftp-master b/bin/debian-ftp-master deleted file mode 100755 index e410c021..00000000 --- a/bin/debian-ftp-master +++ /dev/null @@ -1,158 +0,0 @@ -#!/bin/bash - -# debian-ftp-master -- set up some windows for doing work on Debian's ftp-master - -# Copyright (C) 2019 Sean Whitton -# -# GPL-3 or later - -set -e - -. $HOME/.shenv - -# # require irssi is already raiseable, as starting it is interactive in -# # a way we can't easily wait for -# if ! wmctrl -l | grep -q "irssi"; then -# zenity --error --no-wrap --text="Please attach to irssi first." -# exit 1 -# fi - -# # kill off any broken session (e.g. lost WiFi) -# wmctrl -c "ftp-master session cleanup" ||: -# wmctrl -c "ftp-master dak command session" ||: -# wmctrl -c "ftp-master GNU mc session" ||: -# wmctrl -c "*NEW notes*" ||: -# # wait, in case xfce4-terminal prompted the user -# while wmctrl -l | grep -q -E "ftp-master (session cleanup|dak command session|GNU mc session)"; do -# sleep 1 -# done - -# # If there are no other Emacs frames open, the title of the frame will -# # be emacs@$HOST rather than *NEW notes*, which means we can't control -# # it. So, ensure one is open -# if ! wmctrl -lx | grep -q "emacs.Emacs"; then -# emacsclient -c -a '' -n -e '(switch-to-buffer "*scratch*")' -# fi - -# first establish a control socket, so that the two interactive ssh -# connections don't race to do this and one of them disables multiplexing -ssh -fN ftp-master.debian.org - -# start Emacs on ftp-master -ssh ftp-master.debian.org pgrep -u spwhitton emacs \ - || ssh ftp-master.debian.org emacs --daemon & - -# # open zenity dialog first; i3 will not float it -# zenity --question --no-wrap --no-markup \ -# --title="ftp-master session cleanup" \ -# --text="Kill tmux & Emacs sessions on ftp-master?" & -# zenity_pid=$! -# until wmctrl -l | grep -q "ftp-master session cleanup"; do -# sleep 0.3 -# done - -monitors="$(xrandr -q | grep ' connected' | wc -l)" - -if ! wmctrl -l | grep -q "ftp-master dak command session"; then - first="$(i3-fresh-workspace)" - - xfce4-terminal -x ssh-and-tmux \ - ftp-master.debian.org dak "ftp-master dak command session" - until wmctrl -l | grep -q "ftp-master dak command session"; do - sleep 0.3 - done - wmctrl -R "ftp-master dak command session" - - # if we have the `layout tabbed` above, before any windows are opened, - # the workspace ends up with a tabbed container inside a tabbed - # container on buster's i3 (but not stretch's) - i3-msg layout tabbed - - xfce4-terminal -x ssh-and-tmux \ - ftp-master.debian.org mc "ftp-master GNU mc session" - until wmctrl -l | grep -q "ftp-master GNU mc session"; do - sleep 0.3 - done - wmctrl -R "ftp-master GNU mc session" - - emacsclient -c -a '' -n -e '(progn (switch-to-buffer "*NEW notes*") (text-mode))' - until wmctrl -l | grep -q "*NEW notes*"; do - sleep 0.3 - done - wmctrl -R "*NEW notes*" - - # Now we've the windows opened, arrange them. For some reason, in - # order to have the resize commands take effect, there has to be a - # pause before each resize command is issued, i.e. separate i3-msg - # calls separated by calls to sleep - monwidth="$(xdpyinfo | awk '/dimensions/{print $2}' | cut -dx -f1)" - if [ $monitors -gt 1 ] ; then - second="$(i3-fresh-workspace)" - i3-msg workspace "$first" - # ensure mc window is on primary output, since I spend more time - # in it (I think this is sensible!) - i3-msg move workspace to output primary - # move the dak control window - i3-msg focus left, focus left, move to workspace "$second" - # split windows - i3-msg move up - sleep 0.2 - i3-msg resize set height 70 ppt - # machine-specific: move workspace 9 to the secondary monitor, if - # we know what that's called. Otherwise, user can just manually - # move workspace 9 to the correct monitor right after executing - # this script; workspace 7 will be left displayed on the primary - # monitor - if [ "$(hostname -f)" = "iris.silentflame.com" ]; then - i3-msg workspace "$second" - i3-msg move workspace to output LVDS-1 - i3-msg workspace "$second" - else # no machine-specific config - # ensure dak control window focused - i3-msg workspace "$first" - fi - elif [ $monwidth -ge 1920 ]; then - # three column split (i.e. two mc columns and dak column) should - # work on a monitor this big (after some tweaking of mc's display - # settings) - i3-msg move down, focus up, focus left, move right, move right, move right - sleep 0.2 - i3-msg resize set width 35 ppt, focus left - sleep 0.2 - i3-msg resize set height 65 ppt, focus right - else - # small screen view - i3-msg focus left, split v, focus right, move left - sleep 0.2 - i3-msg resize set height 30 ppt, focus up, focus left - fi -else - wmctrl -a "ftp-master dak command session" - if [ "$(hostname -f)" = "iris.silentflame.com" ] \ - && [ $monitors -gt 1 ]; then - i3-msg move workspace to output LVDS-1 - wmctrl -a "ftp-master GNU mc session" - fi - i3-msg move workspace to output primary -fi - -# ssh athena tmux send-keys -t irssi DOWN -# ssh athena tmux send-keys -t irssi "\"/join -OFTC #debian-ftp-private\"" ENTER -# # ssh athena tmux send-keys -t irssi ! l o c k SPACE N E W -# # ssh athena tmux send-keys -t irssi LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT -# i3-msg '[class="^Xfce4-terminal$" title="^irssi$"]' scratchpad show - -# # finally, get a little more space in the mc session -# ssh ftp-master.debian.org tmux set -t mc status off - -# # clean everything up, per DMUP -# wait $zenity_pid -# zenity_exit=$? -# wmctrl -c "*NEW notes*" ||: -# if [ $zenity_exit = 0 ]; then -# ssh ftp-master.debian.org tmux kill-server -# ssh ftp-master.debian.org pkill -u spwhitton emacs -# sleep 10 -# # --title needs to be different from the above so i3 floats the window -# ssh ftp-master.debian.org pgrep -u spwhitton emacs && zenity --error --no-wrap --title="Session cleanup error" --text="Processes still running on ftp-master!" -# fi diff --git a/bin/develacc-please b/bin/develacc-please deleted file mode 100755 index 63d86ecc..00000000 --- a/bin/develacc-please +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# Boot or resume develacc and open a VNC viewer. Suspend develacc, -# mainly to save battery power, when the viewer is closed. -# -# This is mainly for when I want to work in develacc for a while, full -# screen, almost as if my laptop was running sid. -# -# For work where I expect to be going back and forth between the VM -# and the bare metal host or other VMs, it might be better to access -# the VM via a normal, non-fullscreened virt-manager window rather -# than full screen virt-viewer. Similarly if I have a large monitor -# available, it might be more convenient not to have the VM viewer -# fullscreened - -set -e - -. $HOME/.shenv - -VIRSH="virsh --connect qemu:///system" -develacc="develacc.$(hostname -f)" - -if wmctrl -l | grep -q "$develacc"; then - wmctrl -a "$develacc" -else - if $VIRSH list | grep -q "$develacc .*paused"; then - $VIRSH resume $develacc - elif ! $VIRSH list | grep -q $develacc; then - $VIRSH start $develacc - fi - - virt-viewer -c qemu:///system --hotkeys=release-cursor=ctrl+alt \ - -a -f -r $develacc # \ - # && $VIRSH suspend $develacc & - until wmctrl -l | grep -q "$develacc"; do - sleep 0.3 - done - i3-fresh-workspace --take-along -fi diff --git a/bin/develacc-second-stage b/bin/develacc-second-stage deleted file mode 100755 index 1d95b4e0..00000000 --- a/bin/develacc-second-stage +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -set -e - -. $HOME/.shenv - -# ---- configuration - -FOXIT="$HOME/lib/annex/big/software/FoxitReader.enu.setup.2.4.4.0911.x64.run.tar.gz" -DEVELACC="$HOME/local/develacc" - -# ---- start develacc - -sudo virsh list | grep -q "develacc.$(hostname -f) .*running" \ - || sudo virsh start develacc.$(hostname -f) - -# ---- install FoxitReader - -mkdir -p "$DEVELACC/tmp" -cp -L "$FOXIT" "$DEVELACC/tmp" -( cd "$DEVELACC/tmp" && tar axf $(basename $FOXIT)) -ssh root@develacc "/home/spwhitton/tmp/FoxitReader.enu.setup.*" - -# ---- clone dionysus annex & pair with home directory copy - -# TODO diff --git a/bin/emacsclient b/bin/emacsclient index 89c76443..f9a238c5 100755 --- a/bin/emacsclient +++ b/bin/emacsclient @@ -232,7 +232,7 @@ elif $want_update && ! $want_version; then # Facility to update a (running) daemon's env for a new login session. # This allows us to have the Emacs daemon survive restarts of the # graphical desktop environment, and to update Emacs on a remote host when - # there is a new forwarded SSH agent socket. See 'upenv' in .bash_defns. + # there is a new forwarded SSH agent socket. See 'upenv' in ~/.shinit. # # --spw/update-environment may be combined with a regular request or be # the only thing asked of this script. diff --git a/bin/get-sdf-mail b/bin/get-sdf-mail index 1bc9ab4d..473eea2e 100755 --- a/bin/get-sdf-mail +++ b/bin/get-sdf-mail @@ -2,8 +2,6 @@ set -e -. $HOME/.shenv - uuid=$(date +%s) ssh spw@tty.sdf.org mv /var/mail/spw /sdf/arpa/ns/s/spw/tmp/mbox.$uuid diff --git a/bin/git-develacc b/bin/git-develacc index 0d8178a0..4e8f3671 100755 --- a/bin/git-develacc +++ b/bin/git-develacc @@ -19,8 +19,6 @@ set -e -$HOME/.shenv - # sanity check if in-develacc; then echo >&2 "$0: this script should be run outside the develacc container by my normal user" diff --git a/bin/git-dotfiles-rebase b/bin/git-dotfiles-rebase index b7018a1f..5f96244a 100755 --- a/bin/git-dotfiles-rebase +++ b/bin/git-dotfiles-rebase @@ -1,7 +1,5 @@ #!/bin/sh -. $HOME/.shenv - set -e sign () { diff --git a/bin/git-dotfiles-update-master b/bin/git-dotfiles-update-master index d48290b4..6b575f2d 100755 --- a/bin/git-dotfiles-update-master +++ b/bin/git-dotfiles-update-master @@ -9,8 +9,6 @@ set -e -. $HOME/.shenv - # To update a shallow clone we would do 'git fetch --depth 1' and then 'git # reset --hard origin/master'. But that would leave us vulnerable to an # attacker causing us to check out an older signed commit than the one we have diff --git a/bin/i3-startup-always b/bin/i3-startup-always index 2f2caa0e..c5e937bd 100755 --- a/bin/i3-startup-always +++ b/bin/i3-startup-always @@ -2,8 +2,6 @@ # idempotent X settings -. $HOME/.shenv - xrdb -merge "$HOME/.Xresources" # ---- don't let other local users spawn windows on my main X session diff --git a/bin/insinuate-dotfiles b/bin/insinuate-dotfiles index d7ec9178..2d4d0f91 100755 --- a/bin/insinuate-dotfiles +++ b/bin/insinuate-dotfiles @@ -24,17 +24,15 @@ # to do an update of what's already there, but this will be much slower over # sshfs than the following, which should copy files in just one direction -# Enhancement: When don't have git on remote and src/dotfiles does not -# exist, copy over .bashrc, .inputrc, .shenv, .emacs.d and maybe more, -# unconditionally (i.e. overwrite what's there, in case want to update -# to a newer version). Maybe confirm that I want to do that before -# copying, in case what I would prefer is just to go and install git -# on the remote machine. +# Enhancement: When don't have git on remote and src/dotfiles does not exist, +# copy over .bashrc, .inputrc, .profile, .shinit, .emacs.d and maybe more, +# unconditionally (i.e. overwrite what's there, in case want to update to a +# newer version). Maybe confirm that I want to do that before copying, in +# case what I would prefer is just to go and install git on the remote +# machine. set -e -. $HOME/.shenv - # assume connection sharing is set up in ~/.ssh/config ssh -fN "$1" @@ -1,5 +1,4 @@ #!/bin/sh -. $HOME/.shenv # Prepend logall to a command and its stdout and stderr will be # timestamped and written to a textfile in $HOME/tmp. diff --git a/bin/rt b/bin/rt deleted file mode 100755 index 66c8a864..00000000 --- a/bin/rt +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -. $HOME/.shenv - -# first check that there exist the dirs we need - -if [ ! -e "$HOME/local/rt/watch" -o ! -d "$HOME/local/rt/session" -o ! -d "$HOME/local/rt/incomplete" -o ! -e "$HOME/local/rt/complete" ]; then - echo "I was asked to start rtorrent, but one of the dirs in ~/local/rt is missing" >&2 - echo "(myrepos fixups should do it)" >&2 - exit 1 -fi - -# start rtorrent under dtach if it's not running - -if ! pgrep -u $LOGNAME rtorrent >/dev/null; then - rm -f $HOME/local/rt/session/dtach.socket - TERM=xterm nice -n 19 dtach -n $HOME/local/rt/session/dtach.socket rtorrent -fi - -# if we're not at a dumb terminal (so this script can be shoved in a -# crontab), try to attach what we (maybe) just made - -# this is a bashism -if [ -t 1 ]; then - dtach -a $HOME/local/rt/session/dtach.socket -fi diff --git a/bin/ssh-and-tmux b/bin/ssh-and-tmux index b7154ddf..90eeb2d5 100755 --- a/bin/ssh-and-tmux +++ b/bin/ssh-and-tmux @@ -60,7 +60,7 @@ fi # Go via a login shell such that if there is no root tmux daemon yet, it ends # up with a PATH as though the first tmux session were launched from an -# interactive shell. This affects launching programs directly from tmux +# interactive login shell. This affects launching programs directly from tmux # (e.g. my C-\ e binding) for *all* sessions. # # mosh does execvp directly so for simplicity we assume remote SHELL is bash. diff --git a/bin/usbskelhere b/bin/usbskelhere deleted file mode 100755 index d242e482..00000000 --- a/bin/usbskelhere +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -. $HOME/.shenv -. $HOME/src/dotfiles/lib-src/tputfs.sh - -skelhere () -{ - usbpubkeys - mkdir -p doc bin lib - cp -RLf ~/lib/annex/big/skel/usb/* . - cp ~/src/dotfiles/bin/{apple-setup.sh,dasl-setup.bat} bin - cp -L ~/lib/pro.terminal lib - cp -L "$HOME/lib/annex/doc/sounds/Rainy Mood pomodoro.mp3" lib - zip -j lib/spwhitton.zip lib/*.reg bin/* - # status now you might want to clone ~/lib/dionysus\; see comproc.org -} - -while true; do - read -p "This might overwrite stuff in $(pwd). Is that okay? " yn - case $yn in - [Yy]* ) skelhere; break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done diff --git a/bin/workstation-duplicity b/bin/workstation-duplicity index 23ec9404..f46fd0b9 100755 --- a/bin/workstation-duplicity +++ b/bin/workstation-duplicity @@ -2,8 +2,6 @@ set -e -. $HOME/.shenv - # this should ensure that notify-send works when script is run by crond export XDG_RUNTIME_DIR=/run/user/$(id -u) |