about summary refs log tree commit diff stats
path: root/bin
diff options
context:
space:
mode:
authorEnsa <@>2020-05-01 17:39:45 -0700
committerEnsa <@>2020-05-01 17:39:45 -0700
commit2b52ba86897ed947976d560fc1a1eb1a8499c451 (patch)
treed1a0d2d82a7907d308b99bbd3fc827cfad20f981 /bin
parentc4632455cff4a5097a3a35ad9d0531388776d028 (diff)
downloadcfg-2b52ba86897ed947976d560fc1a1eb1a8499c451.tar.gz
cwm added, general updates, etc
bother
	made the WM detection and X startup file detection more robust
comm-sel
	replaced 6cord with cordless
	made the default case do nothing so it's less annoying
lh
	removed ipc-server garbage
	changed the audio group to allow for streaming audio to mpv
		(this works with livestream audio files)
mbsync-cron
	moved config file to $XDG_CONFIG_HOME/mbsync/mbsyncrc
	made error exits actually error (helps with crontab -n)
	renamed old popmail touch file to something more nominally
	appropriate
		same with notify-send --app-name
cwmrc
	reading it, DEPENDENCIES.md, and `man cwmrc` will more than
	explain everything in here.
	except the commented binds, these are behaviours cwm does not
	have.
completions.ksh
	self-explanatory. read it.
diraliases
	added ~bin for user binaries dir
	added ~ksh for ksh config dir
	added ~pass for password database
kshrc
	added safeguards for ensuring used directories exist
	switched lfcd source to a test and source
prompt.ksh
	better sep symbols
	git branch occupies less space
lfrc
	added auto-upload to ttm.sh, bound to t
init.vim
	switched colourscheme to zellner
	removed syntastic checker specifiers,
		now uses aggregate checks.
	syntastic_c_compiler set to cc, symlink your preferred compiler
	to ~bin/cc
	switched ectags to ctags
	enabled folds
shrc
	ALTSCR: terminal you want to use for programs that already have
	scrollback. set to "$TERMINAL" if you don't have one.
	fiddled with LESS, hopefully better now
	$TODO is the file todo(1) uses.
	ENV: file ksh sources on startup.
6cord.toml
	removed because it's abandoned now.
colors-wal-dwm.h
	removed because i don't use dwm anymore.
dunstrc, zathurarc
	now uses cozette font
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bother16
-rwxr-xr-xbin/comm-sel6
-rwxr-xr-xbin/lh12
-rwxr-xr-xbin/mbsync-cron23
-rwxr-xr-xbin/pw25
5 files changed, 37 insertions, 45 deletions
diff --git a/bin/bother b/bin/bother
index 701b1a4..1d97791 100755
--- a/bin/bother
+++ b/bin/bother
@@ -1,7 +1,21 @@
 #!/bin/sh
 # puts up a critical notification if $HOME/today exists, containing the contents of that file.
+if [ -z "$XFILE" ]; then
+if [ -f $HOME/.xsession ]; then
+	XFILE=xsession
+elif [ -f $HOME/.xinitrc ]; then
+	XFILE=xinitrc
+fi
+fi
+if grep -q "dwm" $XFILE; then
+	WM=dwm
+elif grep -q 'exec' $XFILE; then
+	WM=$(grep 'exec' $XFILE|cut -f 2 -d ' ' -)
+else
+	WM=$(last -1 $XFILE)
+fi
 if [ -f "$HOME"/today ]; then
-	until pgrep -x dwm>/dev/null
+	until pgrep $WM>/dev/null
 	do
 		true
 	done
diff --git a/bin/comm-sel b/bin/comm-sel
index 0678679..6ef97d9 100755
--- a/bin/comm-sel
+++ b/bin/comm-sel
@@ -6,9 +6,9 @@
 if command -v st-altscreen>/dev/null; then
 	TERMINAL="st-altscreen"
 fi
-case "$(dmenu_path|grep -E "epic5$|6cord|scli$"|dmenu -p "choose chat app:")" in
+case "$(dmenu_path|grep -E "epic5$|cordless|scli$"|dmenu -p "choose chat app:")" in
 	epic5) $TERMINAL -c comm -e epic5 -l "$XDG_CONFIG_HOME/epic/epicrc" ensa&;;
-	6cord) $TERMINAL -c comm -e env TERM=xterm 6cord&;;
+	cordless) $TERMINAL -c comm -e cordless&;;
 	scli) $TERMINAL -c comm -e scli&;;
-	*) notify-send "comm-sel error" "invalid program selection"&&return 1;;
+	*) return;;
 esac
diff --git a/bin/lh b/bin/lh
index e4bdf0c..25a2f62 100755
--- a/bin/lh
+++ b/bin/lh
@@ -1,16 +1,14 @@
 #!/bin/sh
 # lh: the Link Handler
 # takes one path or URL as its argument, launches the appropriate program for this.
-### differs from Luke Smith's linkhandler in cleaner code, inclusion of epub/pdf handling, proper interpretation of twitch video URLs, and livestream handling with streamlink (twitch only for now, tipping me off to URL schemes to look for for other streaming sites would be appreciated.)
 
 # if $1 isn't provided, spawn $BROWSER and exit. this allows lh to be used as a pseudo-browser.
 [ -z "$1" ] && exec "$BROWSER"
-
 case "$1" in
 	*mkv|*webm|*mp4)
-		mpv --input-ipc-server=/tmp/mpv-socket$(date +%s) --quiet "$1" >/dev/null 2>&1 & ;;
-	*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*twitch.tv/videos/*)
-		mpv --input-ipc-server=/tmp/mpv-socket$(date +%s) --quiet --ytdl "$1" >/dev/null 2>&1 & ;;
+		mpv "$1" >/dev/null 2>&1 & ;;
+	*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*twitch.tv/videos/*|*twitch.tv/*/v/*)
+		mpv --ytdl "$1" >/dev/null 2>&1 & ;;
 	*twitch.tv/*)
 		STREAMQUAL="$(streamlink "$1"|\
 			grep "Available streams"|tr " " "\n"|grep -E "[0-9]"|tr -d ,|\
@@ -19,8 +17,8 @@ case "$1" in
 	*png|*jpg|*jpe|*jpeg|*gif)
 		IMGPATH="/tmp/$(echo "$1"|sed "s/.*\\///")"
 		curl -sL "$1" >"$IMGPATH"&&sxiv -a "$IMGPATH">/dev/null 2>&1 & ;;
-	*mp3|*m4a|*flac|*aiff|*opus|*mp3?source*)
-		curl -LO "$1" >/dev/null 2>&1 & ;;
+	*mp3|*m4a|*flac|*aiff|*opus|*ogg|*mp3?source*)
+		mpv "$1" >/dev/null 2>&1 & ;;
 	*epub|*pdf|*djvu)
 		BOOKPATH="/tmp/$(echo "$1"|sed "s/.*\\///")"
 		if [ -n "$READER" ]; then
diff --git a/bin/mbsync-cron b/bin/mbsync-cron
index dd69c01..fc611c2 100755
--- a/bin/mbsync-cron
+++ b/bin/mbsync-cron
@@ -6,12 +6,13 @@
 #	there is an internet connection.
 if ! pgrep -u "${USER:=$LOGNAME}" >/dev/null; then
 	printf '%s not logged in. quitting...\n' "$USER" >/dev/stderr
-	exit
+	exit 1;
 elif pgrep -x mbsync >/dev/null; then
 	printf 'mbsync is already running. quitting...\n' >/dev/stderr
-	exit
+	exit 1;
 elif ! ping -q -c 1 1.1.1.1 >/dev/null; then
 	printf 'no internet connection, quitting...\n' >/dev/stderr
+	exit 1;
 fi
 
 export DISPLAY=:0
@@ -21,9 +22,9 @@ if ! [ -d "$XDG_DATA_HOME/neomutt" ]; then
 fi
 # check account for new mail, notify for new content
 syncandnotify() {
-    mbsync "$account">/dev/null 2>&1
-    # $new holds an index of all mail since the last time popmail ran
-    new=$(find "$XDG_DATA_HOME/mail/$account/inbox/new/" -type f -newer "$XDG_DATA_HOME/neomutt/.popmail-last" 2> /dev/null)
+    mbsync -c "$XDG_CONFIG_HOME/mbsync/mbsyncrc" "$account">/dev/null 2>&1
+    # $new holds an index of all mail since the last time mbsync-cron ran
+    new=$(find "$XDG_DATA_HOME/mail/$account/inbox/new/" -type f -newer "$XDG_DATA_HOME/neomutt/.mbsc-last" 2> /dev/null)
     # $newcount is the number of new mails
     newcount=$(printf '%s\n' "$new" | sed '/^\s*$/d' | wc -l | tr -d " ")
     # send $newcount to a file specific to $account
@@ -31,7 +32,7 @@ syncandnotify() {
     printf ' %s' "$newcount" > "$XDG_DATA_HOME/mail/$account/note"
     # don't notify if there isn't new mail
     if [ "$newcount" -gt "0" ]; then
-        notify-send --app-name="popmail" "mail fetcher" "new mail for profile $account! [$newcount]" &
+        notify-send --app-name="mbsync-cron" "mail fetcher" "new mail for profile $account! [$newcount]" &
 	# reduce output if you have a lot of new mail
 	if [ "$newcount" -lt "16" ]; then
         for file in $new; do
@@ -40,7 +41,7 @@ syncandnotify() {
 	    from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed '1!d'| sed '1,/From/s/From: //')
 	    # modified version of broken $subject variable, only prints the first subject line (so forwards are slightly unclear)
             subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | sed '$D' | grep -m 1 '^Subject: ' | sed 's/Subject: //')
-            notify-send --app-name="popmail" "$from:" "$subject" &
+            notify-send --app-name="mbsync-cron" "$from:" "$subject" &
 	    # sleep for half a second to avoid notification clog
 	    sleep .5
         done
@@ -48,10 +49,10 @@ syncandnotify() {
     fi
 }
 
-# if popmail is given arguments, treat them as accounts to get mail from.
+# if mbsync-cron is given arguments, treat them as accounts to get mail from.
 # otherwise, scan the mbsync config to get account names
 if [ "$#" -eq "0" ]; then
-    accounts="$(awk '/^Group/ {print $2}' "$HOME/.mbsyncrc")"
+    accounts="$(awk '/^Group/ {print $2}' "$XDG_CONFIG_HOME/mbsync/mbsyncrc")"
 else
     accounts=$*
 fi
@@ -71,5 +72,5 @@ if cat "$XDG_DATA_HOME"/mail/*/note|grep -q '[1-9]'; then
 else
 	printf '\n'>"$XDG_DATA_HOME/mail/note"
 fi
-#create/update modification time on an empty file that indicates the time of the last run of popmail
-touch "$XDG_DATA_HOME/neomutt/.popmail-last"
+#create/update modification time on an empty file that indicates the time of the last run of mbsync-cron
+touch "$XDG_DATA_HOME/neomutt/.mbsc-last"
diff --git a/bin/pw b/bin/pw
index cec9e54..fa33761 100755
--- a/bin/pw
+++ b/bin/pw
@@ -1,25 +1,4 @@
 #!/bin/sh
-# generates a password of length $1, sends it to stdout if $2 is blank.
-# if $2 is clip, sends it to the X clipboard and clears it after 10 seconds.
-# if $2 is anything else, sends it to the X primary selection and clears it after 10 seconds
-if [ "$1" = "-h" ]; then
-  printf 'usage: %s [-h]|LENGTH [clip|pri]\n' "$(basename $0)">/dev/stderr
-  return 1
-fi
+# generates a password of length $1.
 PW=$(tr -cd "[:alnum:][:punct:]"</dev/urandom|fold -w "$1"|head -1)
-if [ -n "$2" ]; then
-    # streamline selection variation by using $SEL
-    if [ "$2" = "clip" ]; then
-	    SEL="-sel clip"
-    else
-	    SEL=""
-    fi
-    # backgrounds so the user doesn't have to wait 10 seconds to get a prompt again
-      {
-      printf "%s" "$PW"|xclip $SEL -i&&notify-send "Password Generated" "$1-character password generated. It will clear in 10 seconds."
-      sleep 10
-      printf '\0'|xclip $SEL -i&&notify-send "Clipboard Cleared" "Generated password cleared from clipboard."
-      } &
-else
-  printf '%s\n' "$PW"
-fi
+printf '%s\n' "$PW"