about summary refs log tree commit diff stats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bother10
-rwxr-xr-xbin/comm-sel13
-rwxr-xr-xbin/mbsync-cron (renamed from bin/popmail)28
-rwxr-xr-xbin/opener41
-rwxr-xr-xbin/pw29
5 files changed, 96 insertions, 25 deletions
diff --git a/bin/bother b/bin/bother
new file mode 100755
index 0000000..701b1a4
--- /dev/null
+++ b/bin/bother
@@ -0,0 +1,10 @@
+#!/bin/sh
+# puts up a critical notification if $HOME/today exists, containing the contents of that file.
+if [ -f "$HOME"/today ]; then
+	until pgrep -x dwm>/dev/null
+	do
+		true
+	done
+	sleep 0.5
+	notify-send -u critical "DO TODAY:" "$(cat "$HOME"/today)"
+fi
diff --git a/bin/comm-sel b/bin/comm-sel
index f67787f..0678679 100755
--- a/bin/comm-sel
+++ b/bin/comm-sel
@@ -1,9 +1,14 @@
 #!/bin/sh
-# sends a list of communication TUIs (e.g irssi) to dmenu and allows the user to choose one.
+# sends a list of communication TUIs (e.g epic5) to dmenu and allows the user to choose one.
 # class "comm" is added to enable window managers (e.g dwm) to do specific things with them.
-case "$(dmenu_path|grep -E "irssi|6cord|scli$"|dmenu -p "choose chat app:")" in
-	irssi) $TERMINAL -c comm -e irssi --home=$XDG_CONFIG_HOME/irssi&;;
-	6cord) $TERMINAL -c comm -e 6cord&;;
+# st-altscreen is a built of st that doesn't have scrollback or extra keybindings, so it doesn't get in the way of whatever binds clients have.
+# as a result it's lighter than the build of st i use for interactive use.
+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
+	epic5) $TERMINAL -c comm -e epic5 -l "$XDG_CONFIG_HOME/epic/epicrc" ensa&;;
+	6cord) $TERMINAL -c comm -e env TERM=xterm 6cord&;;
 	scli) $TERMINAL -c comm -e scli&;;
 	*) notify-send "comm-sel error" "invalid program selection"&&return 1;;
 esac
diff --git a/bin/popmail b/bin/mbsync-cron
index d1bae9f..dd69c01 100755
--- a/bin/popmail
+++ b/bin/mbsync-cron
@@ -21,23 +21,20 @@ if ! [ -d "$XDG_DATA_HOME/neomutt" ]; then
 fi
 # check account for new mail, notify for new content
 syncandnotify() {
-    # sanitize $account for use in function
-    acc="$(printf '%s\n' "$account" | sed "s/.*\///")"
-    mbsync "$acc">/dev/null 2>&1
+    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/$acc/inbox/new/" -type f -newer "$XDG_DATA_HOME/neomutt/.popmail-last" 2> /dev/null)
+    new=$(find "$XDG_DATA_HOME/mail/$account/inbox/new/" -type f -newer "$XDG_DATA_HOME/neomutt/.popmail-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 $acc
+    # send $newcount to a file specific to $account
     # the preceding space makes generating a status bar string easier.
-    printf ' %s' "$newcount" > "$XDG_DATA_HOME/mail/$acc/note"
+    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 $acc! [$newcount]" &
+        notify-send --app-name="popmail" "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
-	    # broken lines, not sure what they're supposed to do
-            #from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
-            #subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | sed '$D' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
             # Extract subject and sender from mail.
 	    # modified version of broken $from variable, only prints the first from (so forwards are slightly unclear)
 	    from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed '1!d'| sed '1,/From/s/From: //')
@@ -47,6 +44,7 @@ syncandnotify() {
 	    # sleep for half a second to avoid notification clog
 	    sleep .5
         done
+	fi
     fi
 }
 
@@ -65,7 +63,13 @@ do
 done
 
 wait
-# collect all previously created note files and collate them into a file that can be read by a status bar to notify the user of new mails
-printf "$(cat "$XDG_DATA_HOME"/mail/*/note|tr " " "|"|sed 's/|//')\n">"$XDG_DATA_HOME/mail/note"
+## OLD: collect all previously created note files and collate them into a file that can be read by a status bar to notify the user of new mails
+#printf "$(cat "$XDG_DATA_HOME"/mail/*/note|tr " " "|"|sed 's/|//')\n">"$XDG_DATA_HOME/mail/note"
+# use a single symbol to indicate new mail in any maildir
+if cat "$XDG_DATA_HOME"/mail/*/note|grep -q '[1-9]'; then
+	printf ' \n'>"$XDG_DATA_HOME/mail/note"
+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"
diff --git a/bin/opener b/bin/opener
new file mode 100755
index 0000000..755da51
--- /dev/null
+++ b/bin/opener
@@ -0,0 +1,41 @@
+#!/bin/sh
+# opener: opens files according to its contents
+# takes one path as its argument, launches the appropriate program for it
+if ! [ -f "$1" ]; then
+	printf 'file %s does not exist!\n' "$1" >/dev/stderr
+	return 1
+fi
+FILEPATH="$1"
+FILEMIME="$(file -ib "$FILEPATH")"
+echo() {
+	printf '%s\n' "$*"
+}
+case "$FILEMIME" in
+	#ebooks
+	application/epub*|application/pdf|application/postscript|image/vnd.djvu)
+		if [ -n "$READER" ]; then
+			$READER "$FILEPATH">/dev/null 2>&1 &
+		else
+			zathura "$FILEPATH" &
+		fi ;;
+	#videos
+	video/*)
+		mpv --input-ipc-server=/tmp/mpv-socket$(date +%s) --quiet "$FILEPATH" >/dev/null 2>&1 & ;;
+	#images
+	image/*)
+		sxiv -a "$FILEPATH">/dev/null 2>&1 & ;;
+	#audio
+	audio/*)
+		mpv --input-ipc-server=/tmp/mpv-socket$(date +%s) "$FILEPATH" >/dev/null 2>&1 & ;;
+	#text
+	text/*)
+		if [ -n "$EDITOR" ]; then
+			$EDITOR "$FILEPATH">/dev/null 2>&1 &
+		else
+			vi "$FILEPATH" &
+		fi ;;
+	#catchall
+	*)
+		echo "file $(basename "$FILEPATH") could not be opened. its type is $FILEMIME, go tell ensa that opener didn't work" >/dev/stderr
+		return 1 ;;
+esac
diff --git a/bin/pw b/bin/pw
index 140f1dc..cec9e54 100755
--- a/bin/pw
+++ b/bin/pw
@@ -1,14 +1,25 @@
 #!/bin/sh
-# generates a password of length $1, sends it to stdout if $2 isn't clip.
-# if it is clip, sends it to the X clipboard and clears it after 10 seconds.
+# 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]\n' "$(basename $0)">/dev/stderr&&return 1
+  printf 'usage: %s [-h]|LENGTH [clip|pri]\n' "$(basename $0)">/dev/stderr
+  return 1
 fi
-PW=$(tr -cd "[:alnum:][:punct:]"</dev/urandom|fold -w $1|head -1)
-if [ "$2" = "clip" ]; then
-	printf '%s' "$PW"|xclip -sel clip -i&&notify-send "Password Generated" "$1-character password generated. It will clear in 10 seconds."
-	sleep 10
-	printf "\0"|xclip -sel clip -i&&notify-send "Clipboard Cleared" "Generated password cleared from clipboard."
+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"
+  printf '%s\n' "$PW"
 fi