Scripts
I made some "useful" POSIX-compliant scripts in ~/.local/bin/. This document will try to demonstrate what each script can do.
Archive List (als) ~
Lists the contents of the specified archive with human-readable file sizes, modification dates, and names:
-x/--extract; prompts for confirmation, then extracts the archive into the current directory if it contains a single top-level entry, or into a directory named after the archive otherwise.-o/--open; opens the archive in a newstwindow with an interactive extraction prompt, and if it's comic book archive (.cbz,.cbr,.cb7, and.cbt), opens it withzathura.
Backup (backup) ~
Backs up files and directories specified in ~/.local/share/backup-list.txt to a compressed .tar.gz (tarball) archive with everything under a top-level directory, and dumps it to the specified output directory (or the current working directory, if unspecified). See: Backup Guide.
Drive Mounter (mounter) ~
Allows you to mount/unmount drives, including LUKS-encrypted partitions (which it tries to unlock in the terminal, if detected). If no device (/dev/device) is specified, it displays a dmenu prompt listing all available partitions (along with their size, filesystem, label, and mount status) to select and toggle.
It also comes with a --daemon option that runs in the background, monitoring udev events to automatically mount devices when plugged in and clean up directories when removed.
Drives are mounted to directories within /mnt/ (using sudo, so giving permissions to mount/umount/cryptsetup for your user is crucial). Notifications are sent via dunstify to indicate mounting/unmounting success or failure. When eligible non-root drives are available, a new block appears in the status bar (sb-mounter).
Mail/RSS Checker (mail-rss-check) ~
Periodically synchronizes mail accounts using mbsync and refreshes RSS feeds using newsraft every 5 minutes. When aerc is not running, it displays notifications through dunstify for new messages (while newsraft handles notifications for new feed updates itself). It tracks the last synchronization time using ~/.cache/mail-check's modification time, and extracts the sender and subject from each new message.
Mirrorlist Updater (update-mirrors) ~
Fetches and sorts the latest Pacman mirrorlist for both Artix and Arch repositories (using reflector).
MPD notifications (mpd-notify) ~
Displays mpd playback notifications through dunstify, showing the track title, artist, album, playback state, and cached album artwork when available.
mpv Scripts ~
These aren't shell scripts, but they're a useful handful of Lua scripts in ~/.config/mpv/scripts/ that extend mpv beyond the built-in OSC (alongside the third-party mfpbar and thumbfast scripts, used for the progress bar and on-the-fly thumbnails, respectively).
Crop (crop) ~
Rewritten from crop.lua. Lets you select and apply a crop region on the current video, as a filter. Refuses to start while hardware decoding is active, and syncs the resulting rectangle to user-data so other scripts (trim, thumbfast, and thumbyt) can use it.
Download (download) ~
Downloads the currently playing URL with yt-dlp into ~/Downloads/mpv/, carrying over the active subtitle track and the configured ytdl-format. It also shows dunstify notifications for the download, with the completion notification offering an "Open File" action to play it back.
Menu (menu) ~
Rewritten from mdmenu and mpv-quality-menu. Shows dmenu menus for:
playlist; selects a playlist entry.tracklist; selects/toggles a video, audio, or subtitle track.video-quality/audio-quality; selects a specific format from the ones reported byyt-dlp, laid out in aligned columns (resolution, FPS, bitrate, size, codec, etc.), fetching them on demand if not already cached.
Screenshot (subtitles/video) ~
This replaces mpv's default "screenshot" command (with or without subtitles burned in), with the only difference being copying to the clipboard.
SponsorBlock (sponsorblock) ~
Rewritten from mpv_sponsorblock_minimal. Automatically skips segments (sponsor plugs by default, configurable) in YouTube videos, preferring embedded [SponsorBlock] chapters when present and otherwise querying the SponsorBlock API. sponsorblock toggles skipping on and off for the current file.
YouTube Thumbnails (thumbyt) ~
Rewritten from thumbyt. Fetches YouTube's storyboard sprites for the currently playing video and extracts/caches individual timeline hover thumbnails (using ffmpeg) for the OSC. It respects active crop regions from crop.
Trim (trim) ~
Marks an in-point at the current playback position on the first invocation, then cuts out that range into ~/Videos/Recordings/mpv/[filename]/ on the second, either losslessly with -c copy (trim) or re-encoded through ffmpeg using a configurable profile (encode, or encode-<profile> for a named one). It respects active crop regions from crop. Sends a dunstify notification with an "Open Video" action on completion.
Undo (undo) ~
Seeks back to the playback position from before the last seek.
Nohandler (nohandler) ~
Acts as a fallback application for opening files. When a file without a designated default program is opened, this script determines its MIME type (using file) and displays a critical system notification (using dunstify) to inform the user that no handler is configured. Yes, I know... I just didn't find a better name for this one.
Nohandler Generator (nohandler-gen) ~
Generates a fallback nohandler.desktop file in ~/.local/share/applications/ for all unhandled system MIME types. It calculates the difference between available system MIME types (from /usr/share/mime/packages/) and locally handled ones, assigns the leftovers to nohandler, and automatically updates the local desktop database.
Password Prompt (dmenu-pass) ~
Shows a dmenu password prompt for GnuPG, OpenSSH, and sudo.
Program Launcher (dmenu-programs) ~
Launches programs specified in ~/.local/share/applications/ (using dmenu), with a --games option to show programs in the "Game" category.
Screen Capture ~
Scripts used to capture the screen in various ways. The default file timestamp is %Y-%m-%d_%H-%M-%S (ISO 8601).
Screenshot (screenshot) ~
Allows you to capture screenshots (using maim):
--region; prompts the user to select a window or region (viaslop), then captures it.--screen; captures the entire screen.- No options; displays a
dmenumenu to choose between the two modes.
Screenshots are saved as .png files in ~/Pictures/Screenshots/.
Screen Recorder (record) ~
Allows you to make screen recordings (using ffmpeg):
--region; prompts the user to select a window or region (viaslop), then records it.--screen; records the entire screen.--stop; stops an ongoing recording.- No options; displays a
dmenumenu to choose between the two modes, or stop recording.
When recording starts, a new block appears in the status bar (sb-record). Recordings are saved as .mp4 files in ~/Videos/Recordings/.
Statusbar Blocks ~
These scripts can be found under statusbar/, and are invoked by dwmblocks for information on the statusbar:
| Block | Description |
Battery Status (sb-battery) |
Battery state and percentage. |
Internet Network (sb-network) |
Wireless network name. |
Mounted Drives (sb-mounter) |
Mounted drives. |
Recording Status (sb-record) |
Recording status. |
Time (sb-time) |
Time (%H:%M). |
Volume Level (sb-volume) |
Volume level. |
The blocks are clickable and can invoke some useful commands (see: Keybindings > Statusbar (dwmblocks)).
Wallpaper Changer (wallpaper) ~
Changes the wallpaper and generates a respective colorscheme to sync throughout all programs (using wal). If no file is specified, it displays a nsxiv prompt to choose a wallpaper from ~/Pictures/Wallpapers/. If --random is used, a random image from ~/Pictures/Wallpapers/ is chosen.
Wallpaper Colorscheme Generator (wal) ~
Generates a colorscheme from a wallpaper image to sync throughout all programs (the logic of which is both horrible and shamelessly plagiarized from pywal16/wallust). It extracts and clusters colors from the image, calculates a set colors, adjusts them for sufficient contrast and saturation, and renders the resulting colors into templates in ~/.config/wal/ for use by dunst, mpv, xresources, zathura, and a couple of mpv scripts (crop and mfpbar).
Wrappers ~
These scripts wrap different programs to provide small conveniences.
ncmpcpp ~
This wrapper script simply suppresses the Reading configuration from /home/[username]/.config/ncmpcpp/config... message when launching ncmpcpp.
nsxiv ~
This wrapper script handles URLs (using curl) and caches them. It also adds the -a/--animate and -q/--quiet options (to play animations of multi-frame images and disable warnings to standard error stream).