dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 66697133829a698ff3d971e3ee45cfb3b5ea1050
parent 1e9d4aa55997eda1d34ef89f046f7df635d0b491
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Fri, 13 Nov 2020 19:24:27 -0500

Remove my manpages, open script

Diffstat:
Dbin/open | 118-------------------------------------------------------------------------------
Dman/man1/my.1 | 201-------------------------------------------------------------------------------
Dman/man5/my-open.config.5 | 47-----------------------------------------------
3 files changed, 0 insertions(+), 366 deletions(-)

diff --git a/bin/open b/bin/open @@ -1,118 +0,0 @@ -#!/bin/sh -# -# ~/bin/my-open -# -# Every OS seems to use it's own uniquely-named binary to open -# files using the correct handler for the file's MIME type. This is my -# attempt to resolve the different handlers into a platform-independent -# one. -# -if [ "$1" = "-T" ] -then - shift - - configfile="${XDG_CONFIG_HOME:-$HOME/.config}/my-open/config" - - if [ ! -f "$configfile" ] - then - echo "my-open: No config file. Creating skeleton." - mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/my-open" - configname=${configfile/$HOME/'~'} - cat >> "$configfile" <<-EOF -# -# $configname -# -# format: [mimetype]:default fallback1 fallback2 ...:commandline -# second segment of mimetype can be a wildcard. my-open looks for exact -# matches first. -EOF - exit 2 - fi - - if type xdg-mime > /dev/null 2>&1 - then - mimecmd="xdg-mime query filetype %s" - elif type mimetype > /dev/null 2>&1 - then - mimecmd="mimetype %s" - else - echo "my-open: No way to determine MIME type" >&2 - exit 1 - fi - - if [ -f "$1" -o -d "$1" ] - then - mimecmd=`printf "$mimecmd" "$1"` - mimetype=`$mimecmd` - elif echo "$1" | grep -E '^http:\/\/' > /dev/null 2>&1 - then - mimetype='x-scheme-handler/http' - elif echo "$1" | grep -E '^https:\/\/' > /dev/null 2>&1 - then - mimetype='x-scheme-handler/https' - elif echo "$1" | grep -E '^ftp:\/\/' > /dev/null 2>&1 - then - mimetype='x-scheme-handler/ftp' - else - mimetype='application/octet-stream' - fi - - handlers=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ - cut -d ':' -f 2` - cmdline=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ - cut -d ':' -f 3` - if [ -z "$handlers" ] - then - mimetype="`echo $mimetype | cut -d '/' -f 1`/*" - handlers=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ - cut -d ':' -f 2` - cmdline=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ - cut -d ':' -f 3` - fi - if [ -z "$handlers" ] - then - echo "my-open: No handler specified" >&2 - exit 4 - fi - - for h in $handlers - do - if type $h > /dev/null 2>&1 - then - handler=$h - break - fi - done - - if [ -z "$handler" ] - then - echo "my-open: No handler found in \$PATH" >&2 - exit 8 - fi - set -- `printf -- "$cmdline" "$1"` - exec $handler "$@" -fi - -# Find handler, if one is available -if type cygstart > /dev/null 2>&1 -then - handler=cygstart -elif type xdg-open > /dev/null 2>&1 -then - handler=xdg-open -# Most of the following handlers are used within xdg-open, but we should -# check for them anyway since xdg-open doesn't exist -elif type exo-open > /dev/null 2>&1 -then - handler=exo-open -# Because of its ambiguity, open (the macOS handler) should always be -# tested last -elif type open > /dev/null 2>&1 -then - handler=open -else - echo "my-open: No suitable handler found" > /dev/stderr - exit -1 -fi - -$handler "$@" diff --git a/man/man1/my.1 b/man/man1/my.1 @@ -1,201 +0,0 @@ -.TH MY 1 "September 2019" "djmoch 0.0" "DJMOCH Commands Manual" -.SH NAME -my \- utility functions for use across dotfiles and elsewhere -.SH SYNOPSIS -.SY my -\fISUBCOMMAND\fR [\fIARGS\fR] -.YS -.SH DESCRIPTION -\fBmy\fR runs the subcommand specified by \fISUBCOMMAND\/\fR, passing any provided -\fIARGS\/\fR along. Many of the available subcommands amount to a list of providers -which are searched in the $PATH, with the first one found being executed. This -design allows for dotfiles to port across machines with relative ease. -.SH SUBCOMMANDS -.PP -.TP -\fBmailto\fR -Send email. -.sp -Command synopsis: \fBmy\fR \fBmailto\fR [\fIaddress\fR]\fR [\fIsubject\fR] -.TP -\fBsearch\fR -Search DuckDuckGo in the terminal. -.sp -Command synopsis: \fBmy\fR \fBsearch\fR [\fIterm\fR] (shell quoting rules apply) -.TP -\fBterm\fR -Open an X terminal window. This subcommand follows an order of preference for which -terminal emulator is used. -.sp -The current order is: -.sp -1. st -.br -2. urxvtc (if urxvtd is available) -.br -3. urxvt -.br -4. xterm -.br -5. xfce4-terminal -.br -6. gnome-terminal -.TP -\fBlock\fR -Lock the X session. -.TP -\fBwallpaper\fR -Set the xroot color and, if available, set the wallpaper using the feh .fehbg command. -.TP -\fBstandby\fR -Put the machine into hybrid-sleep mode. -.TP -\fBshutdown\fR -Shut down the machine. -.TP -\fBperms\fR -Search for all of the files in \fIHOME\fR beginning with a dot (i.e., a dotfile) and -sets its permissions via chmod to be inaccessible to everyone except the file owner. -.TP -\fBinit\fR -Perform initializations necessary for "moving in." -.sp -Command synopsis: \fBmy\fR \fBinit\fR [\fI\-f\fR][\fI\-c\fR] -.sp -When run with \fI\-f\fR, the command is forced to run completely, even if it has -already been run. When run with \fI\-c\fR, the user crontab is also initialized. -.sp -In addition to optionally initializing the crontab, init initializes custom termcaps, .less, ensures -the login shell is set to /bin/sh, creates an autostart entry for an available screen locker based -on a preference list and availability in \fIPATH\fR, and initializes gpg-agent.conf to point to the -correct pinentry program. Finally, init creates several folders required for proper behavior of -dotfiles. -.sp -When complete, init touches the file $HOME/._.djmoch to act as a flag for the last time the dotfiles -where updated/initialized. See the \fBlogin\fR subcommand for more details of how this file is used. -.TP -\fBopen\fR -Open a file in the configured XDG handler specific to the file's MIME type, or, optionally, in a -configured terminal handler. -.sp -Command synopsis: \fBmy\fR \fBopen\fR [\fI\-T\fR] \fIFILE\fR -.sp -When the \fI\-T\fR flag is provided, the file is opened in a terminal handler configured in a -different file. See my-open.config(5) for more information an how to configure terminal handlers. -.TP -\fBsound\fR -Adjust the sound settings or display sound status. -.sp -Command synopsis: \fBmy\fR \fBsound\fR [\fIstatus\fR] ... -.sp -If the \fIstatus\fR action is provided, then the current status of the sound sinks and sources -is put out. If the status is not requested, then other command arguments should be provided -according to pactl(1). -.TP -\fBkbopts\fR -Set X keyboard options. -.TP -\fBscreen\fR -Set screen options. This is more or less deprecated in favor of autorandr(1). -.TP -\fBbrightness\fR -Sets the brightness of the provided monitor using the xbacklight(1) utility. -.sp -Command synopsis: \fBmy\fR \fBbrightness\fR \fICTRL\fR ... -.sp -The \fICTRL\fR argument should be the name of an attached display device, or the generic -argument "monitor," which simply looks determines the name of the (only) attached display -device. The remaider of the command arguments follow the description in xbacklight(1). -.TP -\fBbattery\fR -Show information about the battery. -.sp -Command synopsis: \fBmy\fR \fBbattery\fR [\fIremaining\fR][\fItotal\fR][\fIpercent\fR] -.sp -The \fIpercent\fR argument will probably be the only one of any interest. The others are -used internally to calculate the percent, and their representation is dependent on the -operating system. -.TP -\fBstatus\fR -Print an embeddable status message showing the remaining battery percentage, the current -weather, and the time. -.TP -\fBi3status\fR -Same as status, but automatically prints the status to stdout every 15 seconds, allowing -it to be used in the status bar of the i3 window manager. -.TP -\fBcopy\fR -An os-independent way to copy text from the terminal into the system clipboard. -.TP -\fBpaste\fR -An os-independent way to paste text from the system clipboard into the terminal. -.TP -\fBnetrc\fR -Parses netrc to return username/password information for use in configuration files or -anywhere a service credential might be required. Note that this subcommand calls out -to a handler written in Python. -.sp -Command synopsis: \fBmy\fR \fBnetrc\fR \fI<server>\fR [\fIlogin\fR][\fIaccount\fR] -[\fIpassword\fR] -.sp -The \fIserver\fR argument should be the fully-qualified domian name of the server whose -credential is being requested. One of the three optional arguments, \fIlogin\fR, -\fIaccount\fR, or \fIpassword\fR may also be provided, in which case only that portion -of the credential will be provided. If none of the optional arguments are provided, then -all three will be returned. All responses are provided on stdout. -.TP -\fBdotfiles\fR -Perform one of several maintanence actions on the dotfiles. -.sp -Command synopsis: \fBmy\fR \fBdotfiles\fR <\fIargument\fR> -.sp -\fIargument\fR may be one of \fIcheck\fR, in which case the ._.djmoch file in consulted -to see when the dotfiles were last updated, or \fIupdate\fR, in which case the dotfiles -are actually updated. Whether or not \fIupdate\fR actually does anything is conditioned -on whether the dotfiles are sourced from a tarfile. If the dotfiles are sourced from a -Git repository, then \fIupdate\fR does nothing. -.TP -\fBcron\fR -Run configured cron tasks. This subcommand should be called either from a user crontab -or a user systemd timer. -.sp -Command synopsis: \fBmy\fR \fBcron\fR [\fIsystemd\fR] -.sp -If the \fIsystemd\fR argument is provided, then the job output is sent to stdout, -otherwise no output is given. -.sp -Any script located in $HOME/lib/cron.d (either physically or via link) will be -executed. Note that cron scripts that are included in the dotfiles are located in -$HOME/lib/cron.avail and must be linked into cron.d before they will be -activated. -.sp -Recall that \fBinit\fR will either place an entry in the user crontab or create a user -systemd timer to call \fBmy cron\fR. -.TP -\fBlogin_async\fR -This should really be called login_sync, since it is the synchronous (i.e. blocking) -version of the login command (see \fBmy login\fR to run as a background job). -.sp -\fBlogin_async\fR will attempt to contact the dotfiles server for up to two minutes -from the point it is called. If it is able to make contact, it consults the ._.djmoch -file to see if the dotfiles have to updated in the past week. If not, it calls \fBmy -dotfiles update\fR. -.TP -\fBlogin\fR -Calls \fBmy login_async\fR as a background job. -.TP -\fBprocesses\fR -List's the current users running processes. -.PP -.SH EXIT STATUS -.PP -.TP -\fB0\fR -\fISUBCOMMAND\fR executed successfully. -.TP -\fB1\fR -Error executing \fISUBCOMMAND\fR. -.PP -.SH SEE ALSO -feh(1), chmod(1), my-open.config(5), pactl(1), autorandr(1), xbacklight(1), crontab(5), -systemd.timer(5) diff --git a/man/man5/my-open.config.5 b/man/man5/my-open.config.5 @@ -1,47 +0,0 @@ -.TH MY-OPEN.CONFIG 5 "September 2019" "djmoch 0.0" "DJMOCH Programmers Manual" -.SH NAME -my-open.config \- terminal MIME handler database -.SH DESCRIPTION -When \fBmy open\fR is called with the \fI-T\fR flag, the my-open.config file -is consulted to determine which handler to use for the requested file's -MIME type. - -The file is assumed to contain multiple rows, with each row constituting one -entry, that is, one MIME type. Similar to the mailcap(4) file, the second -element of a MIME type may be a wildcard, while the first element may not. - -Each entry in my-open.config should follow the format: - -<\fImimetype\fR>:<\fIdefault\fR> [<\fIfallback1\fR> <\fIfallback2\fR> ...]: -\fIfmt\fR - -\fImimtype\fR specifies the MIME type of the file. \fIdefault\fR specifies the -default handler for the given MIME type. The optional \fIfallback\fR arguments -specify fallback handlers to use if the default is not available. \fIfmt\fR -describes how the arguments provided to \fBmy open\fR should be passed along -to the handler. A value of %s for \fIfmt\fR passes the provided file name along -with no additional arguments. - -.SH EXAMPLES -.PP -.TP -text/html:w3m:-T text/html %s -For files of text/html MIME type, use w3m to open the file in the terminal. The -resulting command line will look like: - -w3m -T text/html \fIfilename\fR -.TP -x-scheme-handler/*:w3m lynx:%s -For files of any x-scheme-handler MIME type, use either w3m or lynx to open the -file in the terminal (preferring w3m). The resulting command line will look like: - -w3m|lynx \fIfilename\fR -.PP -.SH FILES -$XDG_CONFIG_HOME/my-open/config - -or - -$HOME/.config/my-open/config -.SH SEE ALSO -my(1)