From c67d4836f4d6d5e6c8ef4e2de38bd21ccb6ee1a1 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 23 Nov 2022 23:35:59 -0700 Subject: 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. --- .bash_defns | 139 ---------------------------- .bash_profile | 3 +- .bashrc | 84 +---------------- .config/notmuch/default/hooks/pre-new | 2 - .emacs.d/eshell/profile | 2 +- .emacs.d/init.el | 5 -- .gitconfig | 2 +- .profile | 53 ++++++++++- .shenv | 164 ---------------------------------- .shinit | 61 +++++++++++++ .xsessionrc | 2 +- archive/.bash_defns | 152 +++++++++++++++++++++++++++++++ archive/.shenv | 107 ++++++++++++++++++++++ archive/bin/bedtime | 17 ++++ archive/bin/debian-ftp-master | 158 ++++++++++++++++++++++++++++++++ archive/bin/develacc-please | 39 ++++++++ archive/bin/develacc-second-stage | 26 ++++++ archive/bin/rt | 25 ++++++ archive/bin/usbskelhere | 25 ++++++ bin/bedtime | 17 ---- bin/debian-ftp-master | 158 -------------------------------- bin/develacc-please | 39 -------- bin/develacc-second-stage | 26 ------ bin/emacsclient | 2 +- bin/get-sdf-mail | 2 - bin/git-develacc | 2 - bin/git-dotfiles-rebase | 2 - bin/git-dotfiles-update-master | 2 - bin/i3-startup-always | 2 - bin/insinuate-dotfiles | 14 ++- bin/logall | 1 - bin/rt | 25 ------ bin/ssh-and-tmux | 2 +- bin/usbskelhere | 25 ------ bin/workstation-duplicity | 2 - lib-src/mr/config | 2 +- 36 files changed, 677 insertions(+), 712 deletions(-) delete mode 100644 .bash_defns delete mode 100755 .shenv create mode 100644 .shinit create mode 100644 archive/.bash_defns create mode 100755 archive/.shenv create mode 100755 archive/bin/bedtime create mode 100755 archive/bin/debian-ftp-master create mode 100755 archive/bin/develacc-please create mode 100755 archive/bin/develacc-second-stage create mode 100755 archive/bin/rt create mode 100755 archive/bin/usbskelhere delete mode 100755 bin/bedtime delete mode 100755 bin/debian-ftp-master delete mode 100755 bin/develacc-please delete mode 100755 bin/develacc-second-stage delete mode 100755 bin/rt delete mode 100755 bin/usbskelhere diff --git a/.bash_defns b/.bash_defns deleted file mode 100644 index d1a994d7..00000000 --- a/.bash_defns +++ /dev/null @@ -1,139 +0,0 @@ -# This file contains core aliases & functions which we want to be available in -# shell commands run from Emacs. - -shopt -s expand_aliases - -# --- aliases - -alias g="git" -alias ga="git annex" -# useful to check whether a rebase introduced any changes to files -alias rld="git diff @{1}..@{0}" -alias athvpn="sshuttle -r athena 0/0 --dns" -alias soffice-pdf="soffice --headless --convert-to pdf" -alias whitenoise="echo -en \"\033]0;whitenoise\a\";\ - cvlc --quiet --loop ~/annex/media/sounds/R*.ogg" - -alias host-suite-build-deps='mk-build-deps -ir -s sudo -t \ - "apt-get --no-install-recommends"' -alias sid-build-deps='mk-build-deps -ir -s sudo -t \ - "apt-get -o Debug::pkgProblemResolver=yes -t sid --no-install-recommends"' -alias bts-policy="bts user debian-policy@packages.debian.org \ - , package debian-policy , " -alias dak-rdeps="ssh mirror.ftp-master.debian.org dak rm -Rn" -alias afsid="apt-file --filter-suites unstable" -alias dinstall="curl https://ftp-master.debian.org/dinstall.status;echo -n 'Right now: ';date -u '+%a %b %d %T %Z %Y (%s)'" -# use with care, in order for this to actually provide a security advantage -alias update-debian-known-hosts="scp master.debian.org:/etc/ssh/ssh_known_hosts ~/src/dotfiles/.ssh/known_hosts_debian" -alias grepcopy="grep --color=always -Eir '(copyright|©)' * | less -R" -# from dgit-user(7), this pushes a non-native package through sbuild -# without an orig.tar for the version in the first changelog entry. -# Useful for sbuilding an unreleased version of a package I maintain -# upstream -alias sbuild-prerelease="sbuild --dpkg-source-opts='-Zgzip -z1 --format=1.0 -sn' --no-run-lintian" - -# alias does not call `git develacc` because we want manual -# verification of what is to be pushed (i.e. `git diff -# master..develacc/develacc-iris` to check patch queue is sane) -alias push-develacc-dotfiles-branch="git push \ - -f origin develacc/develacc-$(hostname -s):develacc-$(hostname -s)" - -alias spin-this-host-now='(cd /usr/local/propellor && sudo ./propellor)' - -# --- environment variables - -export MAKEFLAGS="-j$((2 * $(nproc)))" - -# --- more powerful aliases built with shell functions - -package-plan-unpack () { - ~/src/dotfiles/scripts/debian/package-plan-unpack "$1"; cd "/tmp/$1" -} - -# install package(s) and immediately mark as auto installed, so it -# will get cleaned up by the next autoclean. -# --no-install-recommends is needed as otherwise packages are manually -# installed beyond those specified on the command line -install-as-auto () { - if [[ $EUID -ne 0 ]]; then - sudo apt-get --no-install-recommends install "$@" - sudo apt-mark auto "$@" - else - apt-get --no-install-recommends install "$@" - apt-mark auto "$@" - fi -} - -# PDF word count -pdfwords () { - pdftotext "$1" - | wc -w -} - -# also see soffice-pdf alias above -soffice-pdf-all () { - for f in *.doc *.docx; do - soffice --headless --convert-to pdf "$f" - done -} - -# Debian archive processing logs -alias tail-dak="ssh ftp-master.debian.org tail -F \ - /srv/ftp-master.debian.org/log/current" -alias tail-queued="ssh ssh.upload.debian.org tail -F \ - /srv/upload.debian.org/queued/run/log" -grep-dak () { - ssh ftp-master.debian.org grep "$@" /srv/ftp-master.debian.org/log/current -} -grep-queued () { - ssh ssh.upload.debian.org grep "$@" /srv/upload.debian.org/queued/run/log -} - -# sometimes a remote SSH session cannot get at my forwarded SSH agent -# because an unwanted instance of gpg-agent running on the remote host -# gets in the way. this is a way to kill off that unwanted agent. we -# also need to restart the multiplexed SSH connection to get agent -# forwarding working again. I think this problem is mostly caused by -# the fact that I use gnupg as my SSH agent -kill-remote-gpg () { - ssh "$1" 'rm -f $XDG_RUNTIME_DIR/gnupg/*' - ssh -O exit "$1" -} - -# build debs from a Linux kernel source tree *without* calling `make clean`. -# -# The -dbg deb takes some time to build. To get rid of it when it's -# not needed: scripts/config --disable DEBUG_INFO -bindeb-pkg () { - ver="$(make kernelversion)" - date="$(date +%Y%m%d+%H%M)" - arch="$(dpkg --print-architecture)" - make -j$((2 * $(nproc))) bindeb-pkg \ - LOCALVERSION=-spw \ - KDEB_PKGVERSION=$ver-$date \ - "$@" - echo "sudo apt-get install \ -../linux-{image,headers}-$ver-spw_$ver-${date}_$arch.deb" -} - -# --- host-specific aliases/functions - -# not ftp-master.debian.org - -# this is useful for processing removal requests -# (credits to Mark Wooding) -# -# alternative, by me, but involves spawning another process or two: -# -# command -v dak >/dev/null \ -# || alias dak="perl -MString::ShellQuote \ -# -we'system qw(ssh -t ftp-master.debian.org dak), shell_quote @ARGV'" -if ! command -v dak >/dev/null; then - dak () { - local i - local c= - for i; do # implicit "in $@" - c="$c '${i/\'/\'\\\'\'}'" - done - ssh -t ftp-master.debian.org dak "$c" - } -fi diff --git a/.bash_profile b/.bash_profile index c49349bc..8dd976b3 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1 +1,2 @@ -. $HOME/.bashrc +. ~/.profile +. ~/.bashrc diff --git a/.bashrc b/.bashrc index fa3b3876..30eccf57 100644 --- a/.bashrc +++ b/.bashrc @@ -1,7 +1,4 @@ -# --- preferences - -# load standard environment variables -. $HOME/.shenv +. ~/.shinit # '>' is a nice prompt char because it need not be followed by a # space. It is easy to distinguish the command from the prompt. @@ -29,82 +26,3 @@ HISTSIZE=5000 HISTFILESIZE=5000 HISTIGNORE="ls" # colon-separated shopt -s histappend - -# make less more friendly for non-text input files; see lesspipe(1) -if [ -x /usr/bin/lesspipe ]; then - eval "$(lesspipe)" -fi - -. $HOME/.bash_defns - -# --- aliases - -alias ls="ls --color=auto --literal --classify" -alias grep="grep --colour=auto" - -alias e="$EDITOR" -alias d="emacsclient -cne '(dired \".\")' >/dev/null" -# alias m="emacsclient -c -n -e '(progn (magit-status \".\") \ -# (delete-other-windows))' >/dev/null" -alias ta="tmux new-session -A -s default" -alias rax="screen -URaAx" -alias new-login-shell="exec su -l $USER" # get new UNIX group without relog -alias mrs="src-register-all && mr -m status" -alias gdbmacs="emacsclient -tc -sgdbmacs" - -alias b="bts --mbox show" - -# alias develacc='sudo machinectl shell spw@develacc \ -# $(sudo enter-develacc /bin/sh -c "getent passwd spw | cut -d: -f7")' -# alias develaccr='sudo machinectl shell root@develacc \ -# $(sudo enter-develacc /bin/sh -c "getent passwd root | cut -d: -f7")' - -# --- more powerful aliases built with shell functions - -secs () { - for i in $(seq $1 -1 1); do - echo $i - sleep 1 - done - echo 0 -} - -upenv () { - # don't want to do this outside of tmux as then tmux show-environment will - # show values for the 'default' session which may be irrelevant to us - if [ -n "$TMUX" ]; then - local IFS=$'\n' - for var in $(tmux show-environment | grep -v "^-"); do - eval "export \"$var\"" - done - fi - emacsclient --spw/update-environment - emacsclient -sgdbmacs --spw/update-environment -} - -# --- host-specific aliases/functions - -# ftp-master.debian.org - -if [ -d "/srv/ftp-master.debian.org" ]; then - alias newlocks="cd /srv/ftp-master.debian.org/lock/new/ && ls -l" - newlock () { - touch /srv/ftp-master.debian.org/lock/new/"$1" - } - - newunlock () { - rm /srv/ftp-master.debian.org/lock/new/"$1" - } - - pn () { - cd /srv/ftp-master.debian.org/queue/new - # we need VISUAL=emacsclient because dak's utils.call_editor - # fails when VISUAL contains both the editor's name and some - # arguments to it, as mine does - if [[ $1 ]]; then - VISUAL=emacsclient dak process-new "$1"*changes - else - VISUAL=emacsclient dak process-new -b - fi - } -fi diff --git a/.config/notmuch/default/hooks/pre-new b/.config/notmuch/default/hooks/pre-new index ec132832..2e5d58db 100755 --- a/.config/notmuch/default/hooks/pre-new +++ b/.config/notmuch/default/hooks/pre-new @@ -1,7 +1,5 @@ #!/bin/sh -. $HOME/.shenv - offline || movemymail # ensure that notmuch is able to detect renames by archive-fmail-to-annex diff --git a/.emacs.d/eshell/profile b/.emacs.d/eshell/profile index 42eb0e8a..dccfc2b2 100644 --- a/.emacs.d/eshell/profile +++ b/.emacs.d/eshell/profile @@ -1,4 +1,4 @@ -# for processes spawned by Eshell, drop the -c/-t set in ~/.shenv, so that the +# for processes spawned by Eshell, drop the -t set in ~/.profile, so that the # Emacs frame containing Eshell gets reused, and pass -s if necessary export EDITOR="emacsclient$(if (stringp (daemonp)) (concat \" -s\" (daemonp)) \"\")" export VISUAL="$EDITOR" diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 6fea6cb5..0c05d204 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -699,11 +699,6 @@ Lisp Interaction C-j in `lisp-interaction-mode' and similar." (setenv "TZ" "MST") (set-time-zone-rule "/usr/share/zoneinfo/America/Phoenix")) -(when-let ((bash (executable-find "bash"))) - (setq shell-file-name "bash") - (setenv "SHELL" bash) - (setenv "BASH_ENV" (expand-file-name "~/.bash_defns"))) - ;;; Opening files in external programs ;;; ;;; For years I used the classic `openwith-mode', but it often breaks other diff --git a/.gitconfig b/.gitconfig index e35adabb..a63c3acd 100644 --- a/.gitconfig +++ b/.gitconfig @@ -120,7 +120,7 @@ [format] # There's no tilde expansion for this. When can assume git 2.31 can # set GIT_CONFIG_KEY_0=format.outputDirectory & - # GIT_CONFIG_VALUE_0="$HOME/tmp" in ~/.shenv instead. + # GIT_CONFIG_VALUE_0="$HOME/tmp" in ~/.profile instead. outputDirectory = /home/spwhitton/tmp # ---- merging ---- diff --git a/.profile b/.profile index 5913eec7..4dbd3a99 100755 --- a/.profile +++ b/.profile @@ -1 +1,52 @@ -. $HOME/.shenv +ENV="$HOME/.shinit"; export ENV +PATH="$HOME/local/bin\ +:$HOME/.local/bin\ +:$HOME/src/dotfiles/bin\ +:/usr/sbin:/sbin${PATH:+:$PATH}"; export PATH + +# Either we've Emacs or we consistently fall back to UNIX vi, rather than +# looking for lightweight Emacs clones like mg, which are rarely installed. +# Don't set ALTERNATE_EDITOR: rely on my emacsclient(1) wrapper script. +command -v emacs >/dev/null && EDITOR="emacsclient -t" || EDITOR=vi +export EDITOR +VISUAL=$EDITOR; export VISUAL + +# If want to install an .info file so Emacs can get at it, just: +# +# % cp foo.info ~/local/info +# % install-info ~/local/info/foo.info ~/local/info/dir +# +# Will need to restart Emacs if there was nothing in ~/local/info before this. +INFOPATH="$HOME/local/info:$HOME/.local/info:$INFOPATH" +MANPATH="$HOME/local/share/man:$HOME/.local/share/man:$MANPATH" +export INFOPATH; export MANPATH + +GIT_PAGER=; export GIT_PAGER +GIT_MERGE_AUTOEDIT=no; export GIT_MERGE_AUTOEDIT +PERLDOC=-oman; export PERLDOC +GPG_KEY_ID=0F56D0553B6D411B; export GPG_KEY_ID +# Select the pygments parser for GNU GLOBAL, which works for a lot of +# languages. Override with a gtags.conf in the project root. Assumes have +# /etc/gtags/gtags.conf defining which languages the pygments parser supports. +GTAGSLABEL=pygments; export GTAGSLABEL +if command -v nproc >/dev/null; then + MAKEFLAGS="-j$((2 * $(nproc)))"; export MAKEFLAGS +fi + +MAILDIR="$HOME/.fmail"; export MAILDIR +BROWSER=firefox; export BROWSER +TERMCMD=xfce4-terminal; export TERMCMD +TERMINAL=xfce4-terminal; export TERMINAL + +DEBFULLNAME="Sean Whitton"; export DEBFULLNAME +DEBEMAIL=spwhitton@spwhitton.name; export DEBEMAIL +DGIT_SCHROOT_CHROOT=sid; export DGIT_SCHROOT_CHROOT +DAK_INSPECT_UPLOAD='tmux new-session -d -s mc 2>/dev/null; \ + tmux new-window -n "{changes}" -t mc:^ -k "cd {directory}; mc"' +export DAK_INSPECT_UPLOAD + +if command -v less >/dev/null; then + PAGER=less; export PAGER + LESS="--ignore-case --long-prompt"; export LESS + command -v lesspipe >/dev/null && eval "$(lesspipe)" +fi diff --git a/.shenv b/.shenv deleted file mode 100755 index dc112ae4..00000000 --- a/.shenv +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/sh - -# Environment variables for X and all text-mode shells: bash, Xsession -# and scripts run by cron all source this. So POSIX only. - -# We have calls to `which` which we expect to fail -set +e - -# ---- choose editor depending on what's available - -if [ "$DESKTOP_SESSION" = "i3" ] \ - || [ "$DESKTOP_SESSION" = "xfce" ] \ - || [ "XDG_CURRENT_DESKTOP" = "sway" ]; then - ec_opt="-c" -else - ec_opt="-t" -fi - -# Either GNU Emacs, or UNIX vi -- lightweight Emacs alternatives like mg and -# zile are so rarely installed, so let's have a constant fallback which is -# almost certainly available and which I can use well enough. -# -# Rely on my ~/src/dotfiles/bin/emacsclient wrapper to start up an Emacs -# daemon: don't bother setting ALTERNATE_EDITOR. Check that there's an Emacs -# on (as yet unmodified) PATH, else that wrapper might fail. -if command -v emacs >/dev/null; then - EDITOR="emacsclient $ec_opt" -else - EDITOR="vi" -fi -unset ec_opt -export EDITOR -VISUAL="$EDITOR" -export VISUAL - -# ---- set $PATH - -# this function prepends $addition to $PATH iff $addition isn't -# already in $PATH and $addition is a directory -maybe_add_to_path () -{ - if ! echo $PATH | grep -q "$addition"; then - if [ -d "$addition" ]; then - PATH="$addition:$PATH" - fi - fi -} - -addition="/sbin"; maybe_add_to_path -addition="/usr/sbin"; maybe_add_to_path -addition="/usr/local/bin"; maybe_add_to_path -addition="/usr/pkg/bin"; maybe_add_to_path -addition="$HOME/local/pkg/bin"; maybe_add_to_path -addition="$HOME/local/pkg/sbin"; maybe_add_to_path -addition="$HOME/src/dotfiles/bin"; maybe_add_to_path -addition="$HOME/local/bin"; maybe_add_to_path -addition="$HOME/.cabal/bin"; maybe_add_to_path -addition="$HOME/.local/bin"; maybe_add_to_path -addition="/meta/s/spw/local/src/git-annex.linux"; maybe_add_to_path -unset addition - -export PATH - -# ---- add to $MANPATH - -MANPATH="$HOME/.local/share/man:$MANPATH" -export MANPATH - -# If want to install an .info file so Emacs can get at it, just: -# -# % cp foo.info ~/local/info -# % install-info ~/local/info/foo.info ~/local/info/dir -# -# Will need to restart Emacs if there was nothing in ~/local/info before this. -INFOPATH="$HOME/local/info:" -export INFOPATH - -# ---- package management by Nix: add to $PATH once more - -# # crude heuristic to determine if it's already been added -# if ! echo $PATH | grep -q "$HOME/.nix-profile/bin"; then -# if [ -e "/etc/profile.d/nix.sh" ]; then -# . /etc/profile.d/nix.sh -# fi -# fi - -# ---- set language (snippet from joeyh's home-etc.git repo) - -# TODO: according to , I ought not to -# be setting LC_ALL. Instead I could set most of LC_* to en_GB.UTF-8, -# and some e.g. LC_PAPER to en_US.UTF-8. - -# disabled: propellor setting it system-wide on my machines and that's -# enough - -# case " $(echo $(locale -a)) " in -# *\ en_GB.utf8\ *) LANG=en_GB.utf8 ;; -# *\ en_GB.UTF-8\ *) LANG=en_GB.UTF-8 ;; -# *\ C.UTF-8\ *) LANG=C.UTF-8 ;; -# *\ C.utf8\ *) LANG=C.utf8 ;; -# *) unset LANG ;; -# esac - -# LC_ALL=$LANG -# export LC_ALL -# export LANG - -# ---- further preferences - -GIT_PAGER= -export GIT_PAGER -GIT_MERGE_AUTOEDIT=no -export GIT_MERGE_AUTOEDIT -GPG_KEY_ID=0F56D0553B6D411B -export GPG_KEY_ID -MAILDIR="$HOME/.fmail/" -export MAILDIR -# LD_RUN_PATH="$HOME/local/lib/" -# export LD_RUN_PATH -# LD_LIBRARY_PATH="$HOME/local/lib/" -# export LD_LIBRARY_PATH -BROWSER="firefox" -export BROWSER -TERMCMD="xfce4-terminal" -export TERMCMD -TERMINAL="xfce4-terminal" -export TERMINAL -DEBFULLNAME="Sean Whitton" -export DEBFULLNAME -DEBEMAIL="spwhitton@spwhitton.name" -export DEBEMAIL -DGIT_SCHROOT_CHROOT=sid -export DGIT_SCHROOT_CHROOT -DAK_INSPECT_UPLOAD='tmux new-session -d -s mc 2>/dev/null; tmux new-window -n "{changes}" -t mc:^ -k "cd {directory}; mc"' -export DAK_INSPECT_UPLOAD -PERLDOC="-oman" -export PERLDOC - -# Select the pygments parser for GNU GLOBAL, which works for a lot of -# languages. Override with a gtags.conf in the project root. Relies -# on having /etc/gtags/gtags.conf defining which languages the -# pygments parser works with (available in Debian global package -# version 6.6.4-2 or later, or can copy that file from upstream source -# to ~/.globalrc) -GTAGSLABEL=pygments -export GTAGSLABEL - -# "Setting the monitor port to 0 turns the monitoring function off, -# and autossh will only restart ssh upon ssh's exit." -# -# We rely on ServerAliveInterval and ServerAliveCountMax set in ~/.ssh/config -AUTOSSH_PORT=0 -export AUTOSSH_PORT - -# ---- set pager - -lessf=$(which less) -if [ -x "$lessf" ]; then - PAGER=less - export PAGER - LESS="--ignore-case --long-prompt" - export LESS -fi -unset lessf diff --git a/.shinit b/.shinit new file mode 100644 index 00000000..4201f08b --- /dev/null +++ b/.shinit @@ -0,0 +1,61 @@ +# -*- mode: sh -*- + +if [ "$DESKTOP_SESSION" = i3 -o "$XDG_CURRENT_DESKTOP" = sway ] \ + && command -v emacs >/dev/null; then + EDITOR="emacsclient -c"; VISUAL="$EDITOR" +fi + +ls --version 2>/dev/null | grep -q "GNU coreutils" \ + && alias ls="ls --color=auto --literal --classify" +grep --version 2>/dev/null | grep -q "GNU grep" \ + && alias grep="grep --color=auto" + +alias e="$EDITOR" +alias d="emacsclient -te '(dired \".\")'" +alias ta="tmux new-session -A -s default" +alias rax="screen -URaAx" +alias mrs="src-register-all && mr -m status" +alias gdbmacs="emacsclient -tc -sgdbmacs" +alias g="git" +alias ga="git annex" +# useful to check whether a rebase introduced any changes to files +alias rld="git diff @{1}..@{0}" +alias athvpn="sshuttle -r athena 0/0 --dns" +alias grepcopy="grep --color=always -Eir '(copyright|©)' * | less -R" + +upenv () { + # don't want to do this outside of tmux as then tmux show-environment will + # show values for the 'default' session which may be irrelevant to us + if [ -n "$TMUX" ]; then + local IFS=$'\n' + for var in $(tmux show-environment | grep -v "^-"); do + eval "export \"$var\"" + done + fi + emacsclient --spw/update-environment + emacsclient -sgdbmacs --spw/update-environment +} + +#### Host-specific: ftp-master.debian.org #### + +if [ -d "/srv/ftp-master.debian.org" ]; then + alias newlocks="cd /srv/ftp-master.debian.org/lock/new/ && ls -l" + newlock () { + touch /srv/ftp-master.debian.org/lock/new/"$1" + } + + newunlock () { + rm /srv/ftp-master.debian.org/lock/new/"$1" + } + + pn () { + cd /srv/ftp-master.debian.org/queue/new + # We need VISUAL=emacsclient because dak's utils.call_editor fails + # when VISUAL contains both the editor's name and arguments like -t. + if [ -n "$1" ]; then + VISUAL=emacsclient dak process-new "$1"*changes + else + VISUAL=emacsclient dak process-new -b + fi + } +fi diff --git a/.xsessionrc b/.xsessionrc index 5913eec7..a2c42efa 100644 --- a/.xsessionrc +++ b/.xsessionrc @@ -1 +1 @@ -. $HOME/.shenv +. ~/.profile diff --git a/archive/.bash_defns b/archive/.bash_defns new file mode 100644 index 00000000..2ce59444 --- /dev/null +++ b/archive/.bash_defns @@ -0,0 +1,152 @@ +# This file was for core aliases & functions which we wanted available in +# shell commands run from Emacs. However, nowadays I mostly use +# Eshell, so I moved these back to .shinit. The following code was in +# init.el, and .bashrc *sourced* .bash_defns (BASH_ENV *not* set there): +# +# (when-let ((bash (executable-find "bash"))) +# (setq shell-file-name "bash") +# (setenv "SHELL" bash) +# (setenv "BASH_ENV" (expand-file-name "~/.bash_defns"))) + +shopt -s expand_aliases + +# --- aliases + +alias soffice-pdf="soffice --headless --convert-to pdf" +alias new-login-shell="exec su -l $USER" # get new UNIX group without relog +alias b="bts --mbox show" + +# alias develacc='sudo machinectl shell spw@develacc \ +# $(sudo enter-develacc /bin/sh -c "getent passwd spw | cut -d: -f7")' +# alias develaccr='sudo machinectl shell root@develacc \ +# $(sudo enter-develacc /bin/sh -c "getent passwd root | cut -d: -f7")' + +alias whitenoise="echo -en \"\033]0;whitenoise\a\";\ + cvlc --quiet --loop ~/annex/media/sounds/R*.ogg" + +alias host-suite-build-deps='mk-build-deps -ir -s sudo -t \ + "apt-get --no-install-recommends"' +alias sid-build-deps='mk-build-deps -ir -s sudo -t \ + "apt-get -o Debug::pkgProblemResolver=yes -t sid --no-install-recommends"' +alias bts-policy="bts user debian-policy@packages.debian.org \ + , package debian-policy , " +alias dak-rdeps="ssh mirror.ftp-master.debian.org dak rm -Rn" +alias afsid="apt-file --filter-suites unstable" +alias dinstall="curl https://ftp-master.debian.org/dinstall.status;echo -n 'Right now: ';date -u '+%a %b %d %T %Z %Y (%s)'" +# use with care, in order for this to actually provide a security advantage +alias update-debian-known-hosts="scp master.debian.org:/etc/ssh/ssh_known_hosts ~/src/dotfiles/.ssh/known_hosts_debian" +# from dgit-user(7), this pushes a non-native package through sbuild +# without an orig.tar for the version in the first changelog entry. +# Useful for sbuilding an unreleased version of a package I maintain +# upstream +alias sbuild-prerelease="sbuild --dpkg-source-opts='-Zgzip -z1 --format=1.0 -sn' --no-run-lintian" + +# alias does not call `git develacc` because we want manual +# verification of what is to be pushed (i.e. `git diff +# master..develacc/develacc-iris` to check patch queue is sane) +alias push-develacc-dotfiles-branch="git push \ + -f origin develacc/develacc-$(hostname -s):develacc-$(hostname -s)" + +alias spin-this-host-now='(cd /usr/local/propellor && sudo ./propellor)' + +# --- more powerful aliases built with shell functions + +secs () { + for i in $(seq $1 -1 1); do + echo $i + sleep 1 + done + echo 0 +} + +package-plan-unpack () { + ~/src/dotfiles/scripts/debian/package-plan-unpack "$1"; cd "/tmp/$1" +} + +# install package(s) and immediately mark as auto installed, so it +# will get cleaned up by the next autoclean. +# --no-install-recommends is needed as otherwise packages are manually +# installed beyond those specified on the command line +install-as-auto () { + if [[ $EUID -ne 0 ]]; then + sudo apt-get --no-install-recommends install "$@" + sudo apt-mark auto "$@" + else + apt-get --no-install-recommends install "$@" + apt-mark auto "$@" + fi +} + +# PDF word count +pdfwords () { + pdftotext "$1" - | wc -w +} + +# also see soffice-pdf alias above +soffice-pdf-all () { + for f in *.doc *.docx; do + soffice --headless --convert-to pdf "$f" + done +} + +# Debian archive processing logs +alias tail-dak="ssh ftp-master.debian.org tail -F \ + /srv/ftp-master.debian.org/log/current" +alias tail-queued="ssh ssh.upload.debian.org tail -F \ + /srv/upload.debian.org/queued/run/log" +grep-dak () { + ssh ftp-master.debian.org grep "$@" /srv/ftp-master.debian.org/log/current +} +grep-queued () { + ssh ssh.upload.debian.org grep "$@" /srv/upload.debian.org/queued/run/log +} + +# sometimes a remote SSH session cannot get at my forwarded SSH agent +# because an unwanted instance of gpg-agent running on the remote host +# gets in the way. this is a way to kill off that unwanted agent. we +# also need to restart the multiplexed SSH connection to get agent +# forwarding working again. I think this problem is mostly caused by +# the fact that I use gnupg as my SSH agent +kill-remote-gpg () { + ssh "$1" 'rm -f $XDG_RUNTIME_DIR/gnupg/*' + ssh -O exit "$1" +} + +# build debs from a Linux kernel source tree *without* calling `make clean`. +# +# The -dbg deb takes some time to build. To get rid of it when it's +# not needed: scripts/config --disable DEBUG_INFO +bindeb-pkg () { + ver="$(make kernelversion)" + date="$(date +%Y%m%d+%H%M)" + arch="$(dpkg --print-architecture)" + make -j$((2 * $(nproc))) bindeb-pkg \ + LOCALVERSION=-spw \ + KDEB_PKGVERSION=$ver-$date \ + "$@" + echo "sudo apt-get install \ +../linux-{image,headers}-$ver-spw_$ver-${date}_$arch.deb" +} + +# --- host-specific aliases/functions + +# not ftp-master.debian.org + +# this is useful for processing removal requests +# (credits to Mark Wooding) +# +# alternative, by me, but involves spawning another process or two: +# +# command -v dak >/dev/null \ +# || alias dak="perl -MString::ShellQuote \ +# -we'system qw(ssh -t ftp-master.debian.org dak), shell_quote @ARGV'" +if ! command -v dak >/dev/null; then + dak () { + local i + local c= + for i; do # implicit "in $@" + c="$c '${i/\'/\'\\\'\'}'" + done + ssh -t ftp-master.debian.org dak "$c" + } +fi diff --git a/archive/.shenv b/archive/.shenv new file mode 100755 index 00000000..d461cc84 --- /dev/null +++ b/archive/.shenv @@ -0,0 +1,107 @@ +#!/bin/sh + +# Environment variables for X and all text-mode shells: bash, Xsession +# and scripts run by cron all source this. So POSIX only. + +# We have calls to `which` which we expect to fail +set +e + +# ---- choose editor depending on what's available + +if [ "$DESKTOP_SESSION" = "i3" ] \ + || [ "$DESKTOP_SESSION" = "xfce" ] \ + || [ "XDG_CURRENT_DESKTOP" = "sway" ]; then + ec_opt="-c" +else + ec_opt="-t" +fi + +# Either GNU Emacs, or UNIX vi -- lightweight Emacs alternatives like mg and +# zile are so rarely installed, so let's have a constant fallback which is +# almost certainly available and which I can use well enough. +# +# Rely on my ~/src/dotfiles/bin/emacsclient wrapper to start up an Emacs +# daemon: don't bother setting ALTERNATE_EDITOR. Check that there's an Emacs +# on (as yet unmodified) PATH, else that wrapper might fail. +if command -v emacs >/dev/null; then + EDITOR="emacsclient $ec_opt" +else + EDITOR="vi" +fi +unset ec_opt +export EDITOR +VISUAL="$EDITOR" +export VISUAL + +# ---- set $PATH + +# this function prepends $addition to $PATH iff $addition isn't +# already in $PATH and $addition is a directory +maybe_add_to_path () +{ + if ! echo $PATH | grep -q "$addition"; then + if [ -d "$addition" ]; then + PATH="$addition:$PATH" + fi + fi +} + +addition="/sbin"; maybe_add_to_path +addition="/usr/sbin"; maybe_add_to_path +addition="/usr/local/bin"; maybe_add_to_path +addition="/usr/pkg/bin"; maybe_add_to_path +addition="$HOME/local/pkg/bin"; maybe_add_to_path +addition="$HOME/local/pkg/sbin"; maybe_add_to_path +addition="$HOME/src/dotfiles/bin"; maybe_add_to_path +addition="$HOME/local/bin"; maybe_add_to_path +addition="$HOME/.cabal/bin"; maybe_add_to_path +addition="$HOME/.local/bin"; maybe_add_to_path +addition="/meta/s/spw/local/src/git-annex.linux"; maybe_add_to_path +unset addition + +export PATH + +# ---- package management by Nix: add to $PATH once more + +# # crude heuristic to determine if it's already been added +# if ! echo $PATH | grep -q "$HOME/.nix-profile/bin"; then +# if [ -e "/etc/profile.d/nix.sh" ]; then +# . /etc/profile.d/nix.sh +# fi +# fi + +# ---- set language (snippet from joeyh's home-etc.git repo) + +# TODO: according to , I ought not to +# be setting LC_ALL. Instead I could set most of LC_* to en_GB.UTF-8, +# and some e.g. LC_PAPER to en_US.UTF-8. + +# disabled: propellor setting it system-wide on my machines and that's +# enough + +# case " $(echo $(locale -a)) " in +# *\ en_GB.utf8\ *) LANG=en_GB.utf8 ;; +# *\ en_GB.UTF-8\ *) LANG=en_GB.UTF-8 ;; +# *\ C.UTF-8\ *) LANG=C.UTF-8 ;; +# *\ C.utf8\ *) LANG=C.utf8 ;; +# *) unset LANG ;; +# esac + +# LC_ALL=$LANG +# export LC_ALL +# export LANG + +# ---- further preferences + +# LD_RUN_PATH="$HOME/local/lib/" +# export LD_RUN_PATH +# LD_LIBRARY_PATH="$HOME/local/lib/" +# export LD_LIBRARY_PATH + +# "Setting the monitor port to 0 turns the monitoring function off, +# and autossh will only restart ssh upon ssh's exit." +# +# We rely on ServerAliveInterval and ServerAliveCountMax set in ~/.ssh/config +AUTOSSH_PORT=0 +export AUTOSSH_PORT + diff --git a/archive/bin/bedtime b/archive/bin/bedtime new file mode 100755 index 00000000..d0fda52f --- /dev/null +++ b/archive/bin/bedtime @@ -0,0 +1,17 @@ +#!/bin/bash + +. $HOME/.shenv + +# someday, make this work instead: +# + +(($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/archive/bin/debian-ftp-master b/archive/bin/debian-ftp-master new file mode 100755 index 00000000..e410c021 --- /dev/null +++ b/archive/bin/debian-ftp-master @@ -0,0 +1,158 @@ +#!/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/archive/bin/develacc-please b/archive/bin/develacc-please new file mode 100755 index 00000000..63d86ecc --- /dev/null +++ b/archive/bin/develacc-please @@ -0,0 +1,39 @@ +#!/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/archive/bin/develacc-second-stage b/archive/bin/develacc-second-stage new file mode 100755 index 00000000..1d95b4e0 --- /dev/null +++ b/archive/bin/develacc-second-stage @@ -0,0 +1,26 @@ +#!/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/archive/bin/rt b/archive/bin/rt new file mode 100755 index 00000000..66c8a864 --- /dev/null +++ b/archive/bin/rt @@ -0,0 +1,25 @@ +#!/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/archive/bin/usbskelhere b/archive/bin/usbskelhere new file mode 100755 index 00000000..d242e482 --- /dev/null +++ b/archive/bin/usbskelhere @@ -0,0 +1,25 @@ +#!/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/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: -# - -(($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" diff --git a/bin/logall b/bin/logall index 084ad72a..b802e43d 100755 --- a/bin/logall +++ b/bin/logall @@ -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) diff --git a/lib-src/mr/config b/lib-src/mr/config index 9cd84fe2..ea2a0b8e 100644 --- a/lib-src/mr/config +++ b/lib-src/mr/config @@ -94,7 +94,7 @@ lib = # # here we rely on the fact that ssh already passes argument # # through `/bin/sh -c' (note use of single-quotes in this # # function) -# ssh athena 'cd $HOME/'"$1"' && . $HOME/.shenv && '"$2" +# ssh athena 'cd $HOME/'"$1"' && . $HOME/.profile && '"$2" # } # --- standard procedures -- cgit v1.2.3