Monthly Archive for February, 2024

Install iftop on Oracle Linux 9

dnf install oracle-epel-release-el9
dnf install iftop

iptraf is already in the default repositories.

A good version of ll

A really good version of the ll alias is:

ls –lahF, although on some versions ls –lahp looks better than F.

LS alias and Mozilla DRM bar

Some useful aliases that are not always preconfigured on every Linux version:

alias ll=’ls -alF’
alias la=’ls -A’
alias l=’ls –CF’

To eliminate the DRM warning in Firefox and Librewolf without enable DRM, add this to “userChrome.css”:

 notification[value="drmContentDisabled"]{ display:none !important; }

toolkit.legacyUserProfileCustomizations.stylesheets must be set to true in about config.

Double Sided Scan and PDF

The following script scans PDFs via an auto-document feeder in Hp-Lip and then collates the pages to the correct order when there are reverse sides. No scans will be saved if no data is transmitted for the second set of scans. The second set of scans is the reverse of the pages.

#!/usr/bin/env bash

YMD=$(date +"%Y-%m-%d")
Y=$(date +"%Y")
WORKDIR=/home/username/Temp/
OUTPATH=/home/username/Scans/${Y}/
#  Create a folder, ~/Temp and create a folder, ~/Scans
mkdir -p "/home/username/Scans/${Y}"

hp-scan --adf --mode=color &&
PART=hpscan
LATESTSCAN=`ls -t ${PART}*pdf | sed "1q"`
echo "${LATESTSCAN} ready for ${FILEOUTPUT}"

#  Why you shouldn't parse the output of ls
#  http://mywiki.wooledge.org/ParsingLs 
#  This does not use the FILEOUTPUT variable itself because the cp command
#  seems to have trouble copying the file correctly, even with switches. 

# Thanks Elektropepi at https://github.com/qpdf/qpdf/issues/259
function pdfscanmerge() {
	if [ $# -ne 3 ]; then 
		echo "Usage: pdfscanmerge"; return; fi let odd_pages=$(qpdf --show-npages $1) let even_page=$(qpdf --show-npages $2) argument= for (( odd_page=1; odd_page0 ]; then argument+="$2 $even_page " fi let even_page-- done qpdf --empty --pages $argument -- $3 } cp ${LATESTSCAN} "$WORKDIR$1-uncompressed-scanned-${YMD}.pdf" gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -sOutputFile="$OUTPATH${YMD}-$1.pdf" ${LATESTSCAN} sleep 1 rm -f ${LATESTSCAN} rm -f "$WORKDIR$1-uncompressed-scanned-${YMD}.pdf" killall evince read -p "Load the reverse sides and press any key:" n hp-scan --adf --mode=color && PART=hpscan LATESTSCAN=`ls -t ${PART}*pdf | sed "1q"` echo "${LATESTSCAN} ready for ${FILEOUTPUT}" cp ${LATESTSCAN} "$WORKDIR$1-uncompressed-scanned-reverse-${YMD}.pdf" gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -sOutputFile="$OUTPATH${YMD}-$1-reverse.pdf" ${LATESTSCAN} sleep 1 rm -f ${LATESTSCAN} rm -f "$WORKDIR$1-uncompressed-scanned-reverse-${YMD}.pdf" killall evince pdfscanmerge "$OUTPATH${YMD}-$1.pdf" "$OUTPATH${YMD}-$1-reverse.pdf" "$OUTPATH${YMD}-$1-collated.pdf" rm -f "$OUTPATH${YMD}-$1.pdf" rm -f "$OUTPATH${YMD}-$1-reverse.pdf"