linux

rsync to copy files but keep existing

Contents Intro I had an incomplete set of empty directories and they lacked my backed-up files. I found the backup that had the desired files, and the solution, as I suspected, was rsync1. Since it was music, mostly made into Opus files with abc2, I wanted to recover the files without the physical effort of re-ripping and converting them. Command rsync -a --ignore-existing ./Music/ ~/Music/ Footnotes 1 https://unix.stackexchange.com/questions/149965/how-to-copy-merge-two-directories 2 The original effort with opus files instead of mp3, including a full journey… https://tech.

Mass file conversion using find and exec

convert mp3 to opus The short solution find ./ -type f -name '*.mp3' -exec sh -c 'ffmpeg -i "{}" -f wav - | opusenc --music - "{}.opus"' \; The full journey to the solution The first trick was just to use ffmpeg to convert to .wav, and then to take that .wav output and feed it to opusenc1 ffmpeg -i input.mp3 -f wav - | opusenc –bitrate 256 - output.opus

Renewing gpg keys and subkeys

Intro My encrypted orgmode file in which I store my sensitive information suddenly could be opened, but not edited. When I attempted to save I received: gpg: D664BA060CCB9D32: skipped: Unusable public key gpg: [stdin]: encryption failed: Unusable public key A search online indicated that it was probably due to my gpg keys expiring. With a quick update to the process in 2022 and a belief in the value of limited duplication, here is the winning strategy:

locking repos to avoid installation with zypper dup

** Especially on a rolling distro you sometimes want to avoid certain package updates that might break your system. Note that I’ve aliased sudo zypper to z (which I highly recommend). z addlock Mesa-dri-nouveau

Split/shorten a PDF with pdftk

You can use pdftk to reduce a 150-page PDF to a just the pages you care about. pdftk ORIG_FILE.pdf cat 1-5 output NEW_FILE.pdf

Debug Cron

Suddenly Cron wasn’t running my mail script; I verified that the script itself was still working, so than I began the venture into the unknown: how to debug Cron? Serverfault has a good answer. Everything seemed to checkout, and I verified that it was working to write to a tmp file. The file was being written. Finally, by removing the line that smothers output to /dev/null I was able to find the problem: the need for an absolute path name (as evidently the Cron user couldn’t run getmail without a full path).

Building custom x11 cursors for Linux

I wanted to use the sort of Starcraft game cursors I enjoyed on my windows machine as a teenager, and this was my first thought of custom cursors in Linux. Note that I use EXWM as a low-level window manager, so these instructions should work for most any Linux system. Spoiler: I got it working, but it took a good deal of time that I hope you might be saved. Here is my story.

Printing from the Command Line (and emacs)

Helpful Resource: https://www.cyberciti.biz/tips/linux-unix-sets-the-page-size-to-size.html Command Note lp print with good defaults lpc status all See printer settings lprm clear print jobs export PRINTER='Sharp-MX-2700N’ Set the target printer before printing lpoptions See available options I generally print PDFs, using the excellent pdf-tools. This provides C-c C-p which will print with the $PRINTER and settings you’ve configured, but sometimes you need more customization.

Easily add something to linux system startup

This info worked from the Simplified guide: https://www.simplified.guide/linux/automatically-run-program-on-startup I wanted to start postgresql at startup, because I always end up starting it anyway. As a main-stream application I found it on the list: sudo systemctl list-unit-files --type=service Then I enabled it. sudo systemctl enable postgresql Done! If it hadn’t been on the list I suppose I would have had to make my own unit file for it, thereby adding it to the list.

Gif screencasts from Linux CLI with Byzanz

Wanting to demonstrate the power of emacs M-x butterfly, I needed to make the sort of gif-screen-capture I’ve seen others put to good work. Extra snag: I use emacs itself for a window manager, so the first online recommendation of Peek didn’t work. Instead I found the open-source byzanz to record; however, it requires knowing the screen-portion and length of the gif beforehand. Other than that, though, it worked great even on my exwm (GUI-resistant) system.