dotfiles

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

commit 7de625e4190a0021311ddb9088dd0fff2d80406c
parent 40b40a7cfc7bb30df3ee67228aeccc05bde72e3a
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Mon,  9 Nov 2020 14:54:56 -0500

Cull unused files; break out monolithic 'my' script

Diffstat:
D.curlrc | 4----
D.docutils | 2--
D.editrc | 5-----
D.inputrc | 12------------
D.lessfilter | 14--------------
D.lesskey | 2--
D.minttyrc | 31-------------------------------
D.newsboat/bookmark-pinboard.sh | 26--------------------------
D.newsboat/config | 19-------------------
D.pylintrc | 570-------------------------------------------------------------------------------
D.screenrc | 21---------------------
D.urlview | 3---
D.xbindkeysrc | 53-----------------------------------------------------
Abin/copy | 17+++++++++++++++++
Abin/cron | 15+++++++++++++++
Abin/dotfiles | 2++
Dbin/fws | 16----------------
Mbin/my | 479++-----------------------------------------------------------------------------
Dbin/my-init | 254-------------------------------------------------------------------------------
Abin/my-screen.carbon | 38++++++++++++++++++++++++++++++++++++++
Rbin/my-netrc -> bin/netrc | 0
Abin/num | 3+++
Rbin/my-open -> bin/open | 0
Abin/paste | 17+++++++++++++++++
Rbin/my-perms -> bin/perms | 0
Dbin/sncli-export | 2--
Detc/todoman/todoman.conf | 7-------
27 files changed, 104 insertions(+), 1508 deletions(-)

diff --git a/.curlrc b/.curlrc @@ -1,4 +0,0 @@ -connect-timeout = 10 -user-agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" -referer = ";auto" -header = "Accept: application/json, application/xml, text/plain, */*" diff --git a/.docutils b/.docutils @@ -1,2 +0,0 @@ -[html4css1 writer] -cloak-email-addresses: yes diff --git a/.editrc b/.editrc @@ -1,5 +0,0 @@ -history size 1000 -history unique 1 -bind -e -bind "^W" ed-delete-prev-word -bind "\e[A" ed-search-prev-history diff --git a/.inputrc b/.inputrc @@ -1,12 +0,0 @@ -set vi-cmd-mode-string "[n]" -set vi-ins-mode-string "[i]" -set emacs-mode-string "" -set show-all-if-ambiguous on -set mark-symlinked-directories on -set bell-style visible -Control-Space: menu-complete -"\e[A": history-search-backward -set keymap vi-command -"k": history-search-backward -"L": menu-complete -set keymap emacs diff --git a/.lessfilter b/.lessfilter @@ -1,13 +0,0 @@ -#!/bin/sh - -if [ -d "$1" ] -then - ls -lA "$1" - exit -fi - -case "$1" in -*.tar.gz) gzip -cd $1 | tar -t ;; -*.tar.xz) xz -cd $1 | tar -t ;; -*) exit 1 ;; -esac- \ No newline at end of file diff --git a/.lesskey b/.lesskey @@ -1,2 +0,0 @@ -h left-scroll -l right-scroll diff --git a/.minttyrc b/.minttyrc @@ -1,31 +0,0 @@ -BoldAsFont=-1 -Transparency=off -OpaqueWhenFocused=yes -Font=Consolas -FontHeight=11 -Term=xterm-256color -FontSmoothing=full -CursorType=block -CursorBlinks=no -CursorColour=0,0,0 -ForegroundColour=0,0,0 -BackgroundColour=255,255,255 -Black=0,0,0 -Red=135,0,0 -Green=0,135,95 -Yellow=135,135,0 -Blue=0,95,175 -Magenta=135,87,175 -Cyan=0,128,128 -White=188,188,188 -BoldBlack=58,58,58 -BoldRed=215,0,95 -BoldGreen=135,255,95 -BoldYellow=255,255,95 -BoldBlue=95,175,255 -BoldMagenta=215,135,255 -BoldCyan=135,255,135 -BoldWhite=255,255,255 -BellType=0 -BellFlash=yes -Scrollbar=none diff --git a/.newsboat/bookmark-pinboard.sh b/.newsboat/bookmark-pinboard.sh @@ -1,26 +0,0 @@ -#!/bin/sh -# newsbeuter bookmarking plugin for pinboard -# (c) 2007 Andreas Krennmair -# documentation: https://pinboard.in/api - -username="djmoch" -password="`my-netrc pinboard.in password`" - -# You can enter up to 100 tags here, space delimited, or leave blank for no tag -tags="via:newsbeuter" - -# Leave as 'yes' to bookmark as to be read, enter 'no' to mark as read -toread="yes" - -url="$1" -title="$2" -desc="$3" - -pinboard_url="https://api.pinboard.in/v1/posts/add?url=${url}&description=${title}&extended=${desc}&tags="${tags}"&toread=${toread}" - -output=`wget --http-user=$username --http-passwd=$password -O - "$pinboard_url" 2> /dev/null` -output=`echo $output | sed 's/^.*code="\([^"]*\)".*$/\1/'` - -if [ "$output" != "done" ] ; then - echo "$output" -fi diff --git a/.newsboat/config b/.newsboat/config @@ -1,19 +0,0 @@ -browser "my-open -T %u" -auto-reload yes -macro o set browser "my-open %u" ; open-in-browser ; set browser "my-open -T %u" -ocnews-flag-star "s" -ocnews-login "djmoch" -ocnews-passwordeval "my-netrc nextcloud.djmoch.org password" -ocnews-url "https://nextcloud.djmoch.org" -urls-source "ocnews" -bookmark-cmd "~/.newsboat/bookmark-pinboard.sh" -bind-key j down -bind-key k up - -color background default default -color listnormal default default -color listfocus black white -color listnormal_unread default default bold -color listfocus_unread black white bold -color info blue default reverse -color article default default diff --git a/.pylintrc b/.pylintrc @@ -1,570 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code. -extension-pkg-whitelist= - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS .git - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns=version.* - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. -jobs=1 - -# Control the amount of potential inferred values when inferring a single -# object. This can help the performance when dealing with large functions or -# complex, nested conditions. -limit-inference-results=100 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=no - -# Specify a configuration file. -#rcfile= - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - non-ascii-bytes-literal, - raw-checker-failed, - bad-inline-option, - locally-disabled, - locally-enabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - use-symbolic-message-instead, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - deprecated-operator-function, - deprecated-urllib-function, - xreadlines-attribute, - deprecated-sys-function, - exception-escape, - comprehension-escape - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages. -reports=yes - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expected to -# not be used). -dummy-variables-rgx=_$|dummy - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore. -ignored-argument-names=mock.* - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager, pytest.fixture - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=REQUEST, - acl_users, - aq_parent, - assert_called_once_with, - assert_called_once, - call_count - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=SQLObject, - DateTimeField, - CharField, - ForecastioDataBlock - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - - -[BASIC] - -# Naming style matching correct argument names. -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style. -argument-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming style matching correct attribute names. -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. -attr-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Naming style matching correct class attribute names. -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Naming style matching correct class names. -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming- -# style. -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style. -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names. -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style. -function-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - main, - _ - -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=no - -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Naming style matching correct method names. -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style. -method-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming style matching correct module names. -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style. -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=__.*__ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names. -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style. -variable-rgx=[a-z_][a-z0-9_]{2,30}$ - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )?<?https?://\S+>?$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=8 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=80 - -# Maximum number of lines in a module. -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package.. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[DESIGN] - -# Maximum number of arguments for function / method. -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in an if statement. -max-bool-expr=5 - -# Maximum number of branch for function / method body. -max-branches=20 - -# Maximum number of locals for function / method body. -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body. -max-returns=6 - -# Maximum number of statements in function / method body. -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma. -deprecated-modules=regsub, - TERMIOS, - Bastion, - rexec - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled). -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled). -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled). -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception". -overgeneral-exceptions=Exception diff --git a/.screenrc b/.screenrc @@ -1,21 +0,0 @@ -# -# ~/.screenrc -# - -term screen-256color -altscreen on -bell_msg 'Bell in window %n^G' -backtick 1 15 1 my status -hardstatus on -hardstatus alwayslastline '%{= dr}[%S]%{=b db} %w %=%{-b dd}%1` %{dr}%H' -startup_message off -mousetrack on - -bind h focus left -bind j focus down -bind k focus up -bind l focus right -bind S -bind "'" split -v -bind - split -bind x remove diff --git a/.urlview b/.urlview @@ -1,3 +0,0 @@ -REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):] -COMMAND my open -T - diff --git a/.xbindkeysrc b/.xbindkeysrc @@ -1,53 +0,0 @@ -# -# ~/.xbindkeysrc -# -"xbindkeys_show" - control+shift + q - -"my term" - Mod4 + Return - -"my wallpaper" - Mod1 + Mod4 + w - -"my kbopts" - Mod1 + Mod4 + k - -"my standby" - Mod1 + Mod4 + s - -"my lock" - Mod4 + l - -"eject" - XF86Eject - -"my sound set-sink-volume 0 +10%" - XF86AudioRaiseVolume - -"my sound set-sink-volume 0 -10%" - XF86AudioLowerVolume - -"my sound set-sink-mute 0 toggle" - XF86AudioMute - -"notify-send "`my sound status`"" - Mod4 + v - -"my screen" - Mod1 + Mod4 + Return - -"my shutdown" - control+shift+Mod1 + BackSpace - -"my brightness kbd -inc 10" - XF86KbdBrightnessUp - -"my brightness kbd -dec 10" - XF86KbdBrightnessDown - -"my brightness monitor -inc 10" - XF86MonBrightnessUp - -"my brightness monitor -dec 10" - XF86MonBrightnessDown diff --git a/bin/copy b/bin/copy @@ -0,0 +1,17 @@ +#!/bin/sh + +uname=`uname -s` + +case $uname in + *Darwin*) + reattach-to-user-namespace pbcopy + ;; + *CYGWIN*) + cat > /dev/clipboard + ;; + *Linux*|OpenBSD) + exec xclip + ;; + *) + return +esac diff --git a/bin/cron b/bin/cron @@ -0,0 +1,15 @@ +#!/bin/sh + +case ":$PATH:" in + *:"$HOME/bin":*) ;; + *) PATH="$HOME/bin:$PATH" ;; +esac +cronpath="$HOME/lib/cron.d" +logpath="$HOME/var/log" +for job in $cronpath/* +do + if [ -x $job ] + then + $job > $logpath/`basename $job` 2>&1 + fi +done diff --git a/bin/dotfiles b/bin/dotfiles @@ -0,0 +1,2 @@ +#!/bin/sh +git --git-dir="$HOME/.dotfiles" --work-tree="$HOME" "$@" diff --git a/bin/fws b/bin/fws @@ -1,16 +0,0 @@ -#!/bin/sh -# -# ~/bin/fws -# -# Remove trailing whitespace recursively. Pass in file extensions to -# search for. - -case `uname -s` in - CYGWIN*) ext='\r' ;; - *) ext="" ;; -esac - -for arg -do - find . -name *.$arg -exec sed -i -e "s/[[:space:]]*\$/$ext/g" '{}' \; -done diff --git a/bin/my b/bin/my @@ -1,471 +1,16 @@ #!/bin/sh -# -# ~/bin/my -# -# Command and handlers for them are added as-needed. Some commands only -# have one handler, but exist to avoid re-writes across my dotfiles -# later on. - -[ $# -eq 0 ] && exit 1 - -log="$HOME/var/log/my" -command=$1 -shift - -__mylog() -{ - echo "$1 (`/bin/date +'%m/%d/%Y %H:%M:%S'`): $2" >> $log -} - -__getlocker() -{ - for locker in slock xlock - do - if type $locker >/dev/null 2>&1 - then - echo $locker - exit 0 - fi - done - for locker in light-locker cinnamon-screensaver gnome-screensaver xscreensaver - do - if my processes | grep $locker > /dev/null 2>&1 - then - echo $locker - exit 0 - fi - done - - __mylog "__getlocker" "No screen locker running" - exit 1 -} - -case $command in - mailto) - for m in mutt mail - do - if type $m > /dev/null 2>&1 - then - mailer=$m - break - fi - done - if [ -n "$2" ] - then - $mailer -s "$2" $1 - else - $mailer $1 - fi - ;; - search) - query=`echo $1 | tr ' ' '+'` - exec my open -T https://duckduckgo.com/?q=$query - ;; - term) - if type st > /dev/null 2>&1 - then - exec st "$@" - elif type urxvtd > /dev/null 2>&1 - then - urxvtc "$@" - if [ "$?" -eq 2 ] - then - urxvtd -q -o -f - urxvtc "$@" - fi - exit 0 - elif type urxvt > /dev/null 2>&1 - then - exec urxvt "$@" - elif type xterm > /dev/null 2>&1 - then - exec xterm "$@" - elif type x-terminal-emulator > /dev/null 2>&1 - then - exec x-terminal-emulator "$@" - fi - - [ "$1" = "-e" ] && shift && set -- "-x" $@ - if type xfce4-terminal > /dev/null 2>&1 - then - exec xfce4-terminal "$@" - elif type gnome-terminal > /dev/null 2>&1 - then - exec gnome-terminal "$@" - fi - - __mylog "my term" "No terminal emulator found" - exit 1 - ;; - lock) - sleep 1 - - locker=`__getlocker` - - if [ -z "$locker" ] - then - __mylog "my lock" "no locker running" - exit 1 - fi - case $locker in - light-locker|xlock|slock) : ;; - *) $locker-command -l ;; - esac - exec xset dpms force off - ;; - wallpaper) - if my processes | grep rio >/dev/null 2>&1 - then - return - fi - xsetroot -solid "#444444" - [ -x "$HOME/.fehbg" ] && "$HOME/.fehbg" >> $log 2>&1 - ;; - standby) - if type systemctl > /dev/null 2>&1 - then - locker=`__getlocker` - if [ -z "$locker" ] - then - __mylog "my standby" "no locker running" - exit 1 - fi - if [ ! "$locker" = "light-locker" ] - then - sleep 1 - $locker-command -l - xset dpms force off - fi - exec systemctl hybrid-sleep - else - __mylog "my standby" "No handler found" - fi - ;; - shutdown) - if type systemctl > /dev/null 2>&1 - then - exec systemctl poweroff - elif type poweroff > /dev/null 2>&1 - then - exec my term -e sudo poweroff - else - __mylog "my shutdown" "No handler found" - fi - ;; - perms) - exec my-perms "$@" - ;; - init) - exec my-init "$@" - ;; - open) - exec my-open "$@" - ;; - sound) - if type pactl > /dev/null 2>&1 && pactl stat > /dev/null 2>&1 - then - [ -z "$1" ] && exit 1 - if [ $1 = "status" ] - then - sink_status=`pactl list sinks | grep ^[[:space:]]*Volume | awk '{print $5}'` - source_status=`pactl list sources | grep ^[[:space:]]*Volume | awk '{print $5}'` - echo -n "Sinks: " - for sink in $sink_status - do - echo -n "$sink " - done - echo "" - echo -n "Sources: " - for source in $source_status - do - echo -n "$source " - done - echo "" - exit 0 - else - exec pactl "$@" - fi - else - __mylog "my sound" "No handler found" - fi - ;; - kbopts) - setxkbmap -option -option ctrl:nocaps - ;; - screen) - # defer to local script if it exists - if [ -x "$HOME/bin/my-screen.local" ] - then - exec "$HOME/bin/my-screen.local" "$@" - fi - xrandr_options=`xrandr -q | grep ' disconnected' | awk '{print $1}'` - for option in $xrandr_options - do - xrandr --output $option --off - done - - xrandr_options=`xrandr -q | grep ' connected' | awk '{print $1}'` - numoptions=`echo $xrandr_options | wc -w` - if [ $numoptions -eq 1 ] - then - xrandr --output $xrandr_options --auto --primary - else - # Prefer external monitors - # If more than one display is connected, then enable the - # first non-primary display, and turn off all the others. - primary=`xrandr -q | grep primary | awk '{print $1}'` - - for option in $xrandr_options - do - [ $option = $primary ] && primary_found=1 && continue - [ -n "$primary_found" ] && selection=$option && break - done - - xrandr --output $selection --auto --primary - - for option in $xrandr_options - do - [ $option != $selection ] && xrandr --output $option --off - done - fi - my wallpaper - ;; - brightness) - if type xbacklight > /dev/null 2>&1 - then - if xbacklight -list > /dev/null 2>&1 - then - if [ "$1" = "monitor" ] - then - # Future-proofing ... gmux is specific, imagine other - # systems will be different - for opt in gmux intel_backlight - do - selection=`xbacklight -list | grep $opt` - num=`echo $selection | wc -w` - [ $num -gt 0 ] && break - done - else - selection=`xbacklight -list | grep $1` - num=`echo $selection | wc -w` - fi - [ $num -gt 1 ] && __mylog "my brightness" "More than one $1" && exit 1 - [ $num -lt 1 ] && __mylog "my brightness" "No $1 to adjust" && exit 1 - shift - exec xbacklight -ctrl $selection "$@" - else - if [ "$1" = "monitor" ] - then - shift - exec xbacklight "$@" - else - __mylog "my brightness" "handler incapable of adjusting key brightness" - fi - fi - else - __mylog "my brightness" "No handler found" - fi - ;; - battery) - uname=`uname -s` - - case $1 in - remaining) - case $uname in - *OpenBSD*) - apm -l - ;; - *Linux*) - if [ `acpi | wc -l` -eq 2 ] - then - acpi | awk 'getline' | awk '{print $4}' | sed 's~%~~' | sed 's~,~~' - else - acpi | awk '{print $4}' | sed 's~%~~' | sed 's~,~~' - fi - ;; - *Darwin*) - battery_info=`ioreg -rc AppleSmartBattery` - echo $battery_info | grep -o '"CurrentCapacity" = [0-9]\+' | awk '{print $3}' - ;; - *CYGWIN*) - wmic path Win32_Battery Get EstimatedChargeRemaining /format:list 2>/dev/null | grep '[^[:blank:]]' | cut -d= -f2 - ;; - *) - echo "no battery status" - exit 1 - esac - exit 0 - ;; - total) - case $uname in - *Linux*|*CYGWIN*|*OpenBSD*) - echo 100 - ;; - *Darwin*) - battery_info=`ioreg -rc AppleSmartBattery` - echo $battery_info | grep -o '"MaxCapacity" = [0-9]\+' | awk '{print $3}' - ;; - *) - echo "no battery status" - exit 1 - esac - exit 0 - ;; - percent) - echo "$((`my battery remaining` * 100 / `my battery total`))" - exit 0 - ;; - esac - ;; - status) - echo -n "Batt: `my battery percent`% | " - cat $HOME/var/forecastio/current_forecast.txt | tr -d '\n' - printf " | " - /bin/date +'%l:%M %p' - exit 0 - ;; - i3status) - while : - do - echo "`my status`" || exit 1 - sleep 15 - done - ;; - copy) - uname=`uname -s` - - case $uname in - *Darwin*) - reattach-to-user-namespace pbcopy - ;; - *CYGWIN*) - cat > /dev/clipboard - ;; - *Linux*|OpenBSD) - exec xclip - ;; - *) - return - esac - ;; - paste) - uname=`uname -s` - - case $uname in - *Darwin*) - reattach-to-user-namespace pbpaste - ;; - *CYGWIN*) - cat /dev/clipboard - ;; - *Linux*|OpenBSD) - xclip -o - ;; - *) - return - esac - ;; - netrc) - exec my-netrc "$@" - ;; - dotfiles) - predicate="$1" && shift - case $predicate in - check) - cd "$HOME" - aweekago=$(($(/bin/date +%s) - 604800)) - lastupdate=$(stat --format=%Y ._.djmoch) - [ $lastupdate -lt $aweekago ] && "Dotfiles more than one week old" - ;; - update) - if [ -d "$HOME/.dotfiles_tgz" ] - then - - if type sha256sum > /dev/null 2>&1 - then - sha_exec=sha256sum - fieldnum=1 - else - sha_exec=sha256 - fieldnum=4 - fi +case "$PATH" in +$HOME/bin:*) + ;; +*) + PATH=$HOME/bin:$PATH + export PATH + ;; +esac - curl -s https://git.danielmoch.com/dotfiles/snapshot/dotfiles-master.tar.gz > /tmp/dotfiles.tgz.$$ - oldsum=`$sha_exec "$HOME/.dotfiles_tgz/dotfiles.tar.gz" | cut -d ' ' -f $fieldnum` - newsum=`$sha_exec "/tmp/dotfiles.tgz.$$" | cut -d ' ' -f $fieldnum` - if [ ! "$oldsum" = "$newsum" ] - then - mv /tmp/dotfiles.tgz.$$ "$HOME/.dotfiles_tgz/dotfiles.tar.gz" - cd "$HOME" - tar xzf .dotfiles_tgz/dotfiles.tar.gz - for file in $(ls -A dotfiles-master) - do - cp -r dotfiles-master/$file . - done - rm -rf dotfiles-master - else - rm /tmp/dotfiles.tgz.$$ - fi - fi - my init -f > /dev/null 2>&1 - touch "$HOME/._.djmoch" - ;; - esac - ;; - cron) - [ "$1" = systemd ] && mycron_systemd=1 - case ":$PATH:" in - *:"$HOME/bin":*) ;; - *) PATH="$HOME/bin:$PATH" ;; - esac - cronpath="$HOME/lib/cron.d" - logpath="$HOME/var/log" - for job in $cronpath/* - do - if [ -x $job ] - then - if [ -n "$mycron_systemd" ] - then - $job - else - $job > $logpath/`basename $job` 2>&1 - fi - fi - done - ;; - login_async) - starttime=`/bin/date '+%s'` - runningtime=0 - while [ $runningtime -le 120 ] - do - if ping -c 1 danielmoch.com > /dev/null 2>&1 - then - connected=1 - break - fi - sleep 1 - runningtime=$((`/bin/date '+%s'` - $starttime)) - done - if [ -n "$connected" ] - then - cd "$HOME" - aweekago=$(($(/bin/date +%s) - 604800)) - lastupdate=$(stat -f %m ._.djmoch) - [ $lastupdate -lt $aweekago ] && my dotfiles update - fi - ;; - login) - my login_async & - ;; - processes) - if [ -L /bin/ps ] - then - # busybox - ps -o user,comm= | grep $LOGNAME | awk '{print $2;}' - else - ps -U $LOGNAME -o comm= - fi - ;; - *) echo "my: command $command not found" >&2 +case $# in +[1-9]*) + exec "$@" + ;; esac diff --git a/bin/my-init b/bin/my-init @@ -1,254 +0,0 @@ -#!/bin/sh -# -# ~/bin/my-init -# -# A place to dump run-once type initializations - -while [ -n "$1" ] -do - [ "$1" = "-f" ] && force_init=1 - [ "$1" = "-c" ] && crontab_init=1 - shift -done - -vim_bundle_path="$HOME/.vim/pack/bundle" -configdir=${XDG_CONFIG_HOME:-$HOME/.config} - -__has() -{ - for token in $@ - do - type $token > /dev/null 2>&1 - [ $? -ne 0 ] && echo " $token doesn't exist" && return 1 - done - return 0 -} - -__clone() -{ - dir=`echo "$1" | cut -d '/' -f2` - if [ -d $dir ] - then - echo -n " Updating $1 ..." - cd $dir - git pull > /dev/null 2>&1 - result=$? - cd .. - else - echo -n " Cloning $1 ... " - git clone https://github.com/$1.git > /dev/null 2>&1 - result=$? - fi - [ $result -ne 0 ] && echo "FAILED!" && return 1 - echo "Succeeded" -} - -__optclone_pathogen() -{ - vim --cmd "redir! > /tmp/vimpackages.$$ | silent echo has('packages') | q" - case `cat /tmp/vimpackages.$$` in - *0*) - if [ -d vim-pathogen ] - then - echo -n " Updating tpope/vim-pathogen ..." - cd vim-pathogen - git pull > /dev/null 2>&1 - result=$? - cd .. - else - echo -n " Cloning tpope/vim-pathogen ... " - git clone https://github.com/tpope/vim-pathogen.git > /dev/null 2>&1 - result=$? - fi - [ $result -ne 0 ] && echo "FAILED!" && return 1 - echo "Succeeded" - ;; - esac - rm /tmp/vimpackages.$$ -} - - -if [ -n "$force_init" ] -then - echo "Re-initialization requested" - rm -f "$HOME/._.djmoch" - rm -rf "$HOME/.terminfo" - rm "$HOME/.less" - rm "$HOME/.gnupg/gpg-agent.conf" -fi - -if [ -f "$HOME/._.djmoch" ] -then - echo "Already initialized. Exiting." - exit 0 -fi - -echo "Performing run-once initializations" - -if __has "infocmp" "tic" -then - echo " Initializing Termcaps" - if infocmp tmux-256color > /dev/null 2>&1 - then - tic "$HOME/lib/terminfo/tmux.terminfo" - else - tic "$HOME/lib/terminfo/tmux-from-screen.terminfo" - fi -fi - -if __has "lesskey" -then - echo " Initializing .less" - lesskey -fi - -if my processes | grep systemd > /dev/null 2>&1 \ - && [ -n "$crontab_init" ] -then - echo " Installing systemd timers" - cat >> $configdir/systemd/user/my-cron.service <<-EOF -[Unit] -Description=djmoch "my cron" service - -[Service] -Type=simple -ExecStart=$HOME/bin/my cron systemd -EOF - cat >> $configdir/systemd/user/my-cron.timer <<-EOF -[Unit] -Description=djmoch "my cron" timer - -[Timer] -OnBootSec=1min -OnUnitActiveSec=15min - -[Install] -WantedBy=timers.target -EOF - systemctl --user enable my-cron.timer -elif __has "crontab" && [ -n "$crontab_init" ] -then - echo " Installing crontab" - crontab -l > /tmp/crontab.$$.orig - [ $? -ne 0 ] && echo "" > /tmp/crontab.$$.orig - grep bin/my /tmp/crontab.$$.orig > /dev/null 2>&1 - if [ ! $? -eq 0 ] - then - cat >> /tmp/crontab.$$ <<-EOF -# crontab created by my-init on `date '+%m/%d/%Y'` -# m h dom mon dow command -*/15 * * * * "\$HOME/bin/my" cron - -# Entries below this line created manually -EOF - cat /tmp/crontab.$$.orig >> /tmp/crontab.$$ - cat /tmp/crontab.$$ | crontab - rm /tmp/crontab.$$ - fi - rm /tmp/crontab.$$.orig -fi - -# Vim plugins -if __has "vim" "git" -then - echo " Downloading Vim plugins" - # Plugins that should always be enabled - mkdir -p $vim_bundle_path/start - cd $vim_bundle_path/start - __clone romainl/Apprentice - __clone tpope/vim-commentary - __clone tpope/vim-eunuch - __clone tpope/vim-fugitive - __clone tpope/vim-obsession - __clone tpope/vim-scriptease - __clone tpope/vim-surround - __clone tpope/vim-unimpaired - __clone tpope/vim-vinegar - __clone junegunn/goyo.vim - __clone junegunn/limelight.vim - __clone beloglazov/vim-online-thesaurus - __clone chr4/sslsecure.vim - __optclone_pathogen - cd - > /dev/null 2>&1 - - # Plugins used optionally - mkdir -p $vim_bundle_path/opt - cd $vim_bundle_path/opt - __clone jpalardy/vim-slime - __clone skammer/vim-css-color - cd - > /dev/null 2>&1 - - vim --cmd 'silent! execute "helptags ALL" | q' - unset vim_bundle_path -fi - -for shell in ksh dash sh -do - preferred_shell=`cat /etc/shells | grep /$shell$ | tr '\n' ' ' | cut -d ' ' -f 1` - [ "$preferred_shell" = "" ] || break -done -if getent passwd | grep ^$LOGNAME.*$preferred_shell$ > /dev/null 2>&1 -then - echo " Login shell already set to $preferred_shell" -else - echo " Setting login shell to $preferred_shell" - chsh -s $preferred_shell -fi - -for locker in xscreensaver light-locker cinnamon-screensaver -do - if type $locker > /dev/null 2>&1 - then - echo " Creating autostart entry for $locker" - cat > "${XDG_CONFIG_HOME:-$HOME}/.config/autostart/$locker.desktop" <<-EOF -[Desktop Entry] -TryExec=$locker -Exec=$locker -Name=$locker -Comment=Screen locker -Type=Application -EOF - break - fi -done - -if [ ! -f "$HOME/.gnupg/gpg-agent.conf" ] -then - echo " Creating gpg-agent.conf and configuring pinentry" - pinentry="" - if type pinentry > /dev/null 2>&1 - then - pinentry=`which pinentry` - fi - case `uname -s` in - *Darwin*) - pinentry="/usr/local/bin/pinentry-mac $pinentry" - ;; - esac - - for testpath in $pinentry - do - if [ -x $testpath ] - then - cat > "$HOME/.gnupg/gpg-agent.conf" <<-EOF -default-cache-ttl 600 -max-cache-ttl 7200 -enable-ssh-support -pinentry-program $testpath -EOF - break - fi - done -fi - -[ ! -d "$HOME/var/log" ] && mkdir -p "$HOME/var/log" -[ ! -d "$HOME/var/forecastio" ] && mkdir -p "$HOME/var/forecastio" -[ ! -d "$HOME/lib/cron.d" ] && mkdir -p "$HOME/lib/cron.d" -[ ! -f "$HOME/var/forecastio/current_forecast.txt" ] && echo \ - "Weather not available" > \ - "$HOME/var/forecastio/current_forecast.txt" -[ ! -d "$HOME/.vim/undo/" ] && mkdir -p "$HOME/.vim/undo" -touch "$HOME/._.djmoch" -chmod 000 "$HOME/._.djmoch" - -unset __clone __has __optclone_pathogen diff --git a/bin/my-screen.carbon b/bin/my-screen.carbon @@ -0,0 +1,38 @@ +#!/bin/sh + +expected="eDP-1 DP-1-3" + +for mon in $expected +do + if xrandr -q | grep $mon | grep ' connected' >/dev/null 2>&1 + then + connected="$connected $mon" + else + disconnected="$disconnected $mon" + fi +done + +cmd="xrandr --dpi eDP-1" + +for mon in $connected +do + if [ "$mon" = "eDP-1" ] + then + cmd="$cmd --output eDP-1 --auto --primary" + elif [ "$mon" = "DP-1-3" ] + then + cmd="$cmd --output DP-1-3 --auto --right-of eDP-1 --scale 2x2" + fi +done + +for mon in $disconnected +do + cmd="$cmd --output $mon --off" +done + +echo "my-screen.local: Running cmd $cmd" >> "$HOME/var/log/my" +$cmd +if [ "$1" != "rio" ] +then + my wallpaper +fi diff --git a/bin/my-netrc b/bin/netrc diff --git a/bin/num b/bin/num @@ -0,0 +1,3 @@ +num() { + pr -tn "$1" | $PAGER +} diff --git a/bin/my-open b/bin/open diff --git a/bin/paste b/bin/paste @@ -0,0 +1,17 @@ +#!/bin/sh + +uname=`uname -s` + +case $uname in + *Darwin*) + reattach-to-user-namespace pbpaste + ;; + *CYGWIN*) + cat /dev/clipboard + ;; + *Linux*|OpenBSD) + xclip -o + ;; + *) + return +esac diff --git a/bin/my-perms b/bin/perms diff --git a/bin/sncli-export b/bin/sncli-export @@ -1,2 +0,0 @@ -#!/bin/sh -awk 'BEGIN{getline; getline}{print}' > ~/Downloads/$1 diff --git a/etc/todoman/todoman.conf b/etc/todoman/todoman.conf @@ -1,7 +0,0 @@ -[main] -# A glob expression which matches all directories relevant. -path = ~/lib/share/calendars/nextcloud/* -date_format = %Y-%m-%d -time_format = %H:%M -default_list = Tasks: Home -default_due = 48