From 9c7f0f36b2d6cc93e0e8079ef51d2d7f5b74280b Mon Sep 17 00:00:00 2001 From: foo-dogsquared Date: Mon, 23 Dec 2019 11:44:26 +0800 Subject: [PATCH] Update executable scripts --- bin/askpass | 6 ++++++ bin/choose-manual | 52 ++++++++++++++++++++++++++++++++++++++++++++++ bin/commit-pkglist | 9 ++++++++ bin/prompt | 6 ++++++ bin/toggle-bin | 29 ++++++++++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 bin/askpass create mode 100644 bin/choose-manual create mode 100644 bin/commit-pkglist create mode 100644 bin/prompt create mode 100644 bin/toggle-bin diff --git a/bin/askpass b/bin/askpass new file mode 100644 index 0000000..c98de79 --- /dev/null +++ b/bin/askpass @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +# This is the askpass program that `sudo -a` uses. +# This script should be set with the `SUDO_ASKPASS` environment variable. + +rofi -dmenu -p "Password: " -password \ No newline at end of file diff --git a/bin/choose-manual b/bin/choose-manual new file mode 100644 index 0000000..31f0a0d --- /dev/null +++ b/bin/choose-manual @@ -0,0 +1,52 @@ +#!/usr/bin/env sh + +# This is based from the `mansplain` script by Luke Smith. +# Video reference is at https://www.youtube.com/watch?v=8E8sUNHdzG8. +# There's not much room for customizability so you'll have to edit the script itself if you want something different. + +# Minimum requirements as of writing this script at 2019-12-18: +# * man - v2.9.0 +# * xargs - v4.7.0 +# * rofi - v1.5.4 +# * awk - v5.0.1 + +# Optional dependencies: +# * zathura - v0.4.4 +# * girara - v0.3.3 +# * pdf-mupdf - v0.3.5 + +help_section="Provides an interface for viewing all available manual pages. + +Usage: + $0 [-h, --help] [--viewpdf] [--viewer ] + +Options: + -h, --help - View the help section. + --viewpdf - View the manual as a PDF. +" + +VIEW_PDF=0; + +while [[ $# -gt 0 ]] +do + case $1 in + -h|--help) + echo "$help_section" + exit 0;; + --viewpdf) + VIEW_PDF=1 + shift;; + *) + shift;; + esac +done + +COMMAND_STRING="man -k . | rofi -dmenu -p | awk '{print \$1}' | xargs -r man" + +if [[ $VIEW_PDF -eq 1 ]]; then + COMMAND_STRING+=" -Tpdf | zathura - " +fi + +eval "$COMMAND_STRING" + +exit $? diff --git a/bin/commit-pkglist b/bin/commit-pkglist new file mode 100644 index 0000000..b736445 --- /dev/null +++ b/bin/commit-pkglist @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +# Simply commits the package lists `packages.txt` and `aur-packages.txt` into the Git repo. +# This script is specifically used for a cron job where this is run monthly. + +DOTFILES_DIRECTORY="$HOME/dotfiles" + +git add "$DOTFILES_DIRECTORY/packages.txt" "$DOTFILES_DIRECTORY/aur-packages.txt" +git commit -m "Update package lists as of $(date +%F)" \ No newline at end of file diff --git a/bin/prompt b/bin/prompt new file mode 100644 index 0000000..87c5c63 --- /dev/null +++ b/bin/prompt @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +# A simple prompt script. +# Based from Luke Smith's prompt script. +# https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/prompt + +([ "$(printf "No\\nYes" | rofi -dmenu -p "$1")" = "Yes" ] && $2) || notify-send "The command "$2" failed to execute." diff --git a/bin/toggle-bin b/bin/toggle-bin new file mode 100644 index 0000000..f9757cc --- /dev/null +++ b/bin/toggle-bin @@ -0,0 +1,29 @@ +#!/usr/bin/env sh + +# Dependencies: +# * echo +# * kill +# * pgrep from procps-ng 3.3.15 + +help_usage="Close if the program is already running. +Otherwise, open the specified program. + +Useful for programs that should have one instance running +at a time. + +Note that it uses pgrep for searching the existance of +the program. + +Usage: $0 +" + +if [[ $# -lt 1 ]]; then + echo "$help_usage" + exit 0 +fi + +kill $(pgrep $1) 2>/dev/null +if [[ $? != 0 ]]; then + $1 2>/dev/null +fi +