~dricottone/my-utils

bd3376e8c0886537cc11a2ec78ce5752f79fb58f — Dominic Ricottone 3 years ago e5e6223
Add rmold and resetx
4 files changed, 59 insertions(+), 0 deletions(-)

M Makefile
M README.md
A src/resetx
A src/rmold
M Makefile => Makefile +4 -0
@@ 31,6 31,8 @@ install: clean
	install -m755 src/qemu-test $(BIN_DIR)/qemu-test
	install -m755 src/rand $(BIN_DIR)/rand
	install -m755 src/rebom $(BIN_DIR)/rebom
	install -m755 src/resetx $(BIN_DIR)/resetx
	install -m755 src/rmold $(BIN_DIR)/rmold
	install -m755 src/rmtar $(BIN_DIR)/rmtar
	install -m755 src/rmzip $(BIN_DIR)/rmzip
	install -m755 src/start-at $(BIN_DIR)/start-at


@@ 83,6 85,8 @@ uninstall:
	rm $(BIN_DIR)/qemu-test
	rm $(BIN_DIR)/rand
	rm $(BIN_DIR)/rebom
	rm $(BIN_DIR)/resetx
	rm $(BIN_DIR)/rmold
	rm $(BIN_DIR)/rmtar
	rm $(BIN_DIR)/rmzip
	rm $(BIN_DIR)/start-at

M README.md => README.md +2 -0
@@ 19,6 19,8 @@ mktar     |Wrapper around `tar` for easier compression                   |`bash`
pingable  |Check if an address/name is ping-able                         |`ping`
rand      |Get a random number within an inclusive range                 |`bash`, `shuf`
rebom     |Add BOM to a target file
resetx    |Reset X server monitor configuration                          |`xrandr`
rmold     |Delete old files
rmtar     |Delete 'tar' archive files
rmzip     |Delete 'zip' archive files
start-at  |After a pattern is matched, re-print                          |GNU or New (AT&T) `awk`

A src/resetx => src/resetx +30 -0
@@ 0,0 1,30 @@
#!/bin/sh

name="resetx"
version="1.0"
help_message=$(/usr/bin/cat <<-EOF
	Reset X11 server monitor configuration
	Usage: resetx
	Options:
	 -h, --help     print this message and exit
	 -q, --quiet    suppress error messages
	 -v, --version  print version number and exit
EOF
)

. /usr/local/lib/myminiparse.sh

if [ ! -f "${HOME}/.xinitrc" ]; then
  if [ $quiet -eq 0 ]; then
    (>&2 /usr/bin/printf "Cannot locate X11 server monitor configuration\n" "$name")
  fi
  exit 1
elif ! check-x; then
  if [ $quiet -eq 0 ]; then
    (>&2 /usr/bin/printf "X11 server is not running\n" "$name")
  fi
  exit 1
fi

sudo $(grep -e '^xrandr ' "${HOME}/.xinitrc")


A src/rmold => src/rmold +23 -0
@@ 0,0 1,23 @@
#!/bin/sh

name="rm-old"
version="1.0"
help_message=$(/usr/bin/cat <<-EOF
	Delete files older than a year
	Usage: rm-old [PATH]
	Options:
	 -h, --help     print this message and exit
	 -v, --version  print version number and exit
EOF
)

. /usr/local/lib/myminiparse.sh

if [ -z "$1" ]; then
  path="."
else
  path="$1"
fi

find "$path" -type f -mtime +365 -delete