From e371d9edd474bcf89cf5d462eaccb8638900b390 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sat, 3 Oct 2020 19:27:15 -0400 Subject: Initial commit --- .local/bin/Rinstall | 5 + .local/bin/aliasgen | 14 ++ .local/bin/bars | 22 ++ .local/bin/blocks | 3 + .local/bin/bloks | 59 +++++ .local/bin/bonsai | 554 ++++++++++++++++++++++++++++++++++++++++++++++ .local/bin/camtoggle | 4 + .local/bin/colorbars | 38 ++++ .local/bin/colorbars-sm | 35 +++ .local/bin/colorscheme | 27 +++ .local/bin/compiler | 40 ++++ .local/bin/cronbat | 8 + .local/bin/crontog | 5 + .local/bin/datetime | 3 + .local/bin/define | 3 + .local/bin/displaymenu | 73 ++++++ .local/bin/displayselect | 72 ++++++ .local/bin/dna | 46 ++++ .local/bin/dropbox-status | 9 + .local/bin/dropdowntoggle | 17 ++ .local/bin/dwmbar | 26 +++ .local/bin/dwmbar-battery | 22 ++ .local/bin/emoji-copy | 20 ++ .local/bin/extract | 41 ++++ .local/bin/fixaudio | 8 + .local/bin/gd2pdf | 3 + .local/bin/getbib | 14 ++ .local/bin/groffdown | 54 +++++ .local/bin/kblayout | 3 + .local/bin/layouttoggle | 24 ++ .local/bin/linkhandler | 22 ++ .local/bin/makestereo | 9 + .local/bin/manualgen | 19 ++ .local/bin/mountmenu | 61 +++++ .local/bin/newsup | 15 ++ .local/bin/opout | 11 + .local/bin/pacman-colors | 48 ++++ .local/bin/pipes | 136 ++++++++++++ .local/bin/pipesx | 207 +++++++++++++++++ .local/bin/pod-dl | 30 +++ .local/bin/podentr | 5 + .local/bin/powermenu | 11 + .local/bin/printermenu | 3 + .local/bin/qndl | 13 ++ .local/bin/queueandnotify | 15 ++ .local/bin/rain | 100 +++++++++ .local/bin/recordmenu | 105 +++++++++ .local/bin/rssadd | 9 + .local/bin/screenstatus | 4 + .local/bin/setbg | 20 ++ .local/bin/shortcutgen | 54 +++++ .local/bin/slendy | 35 +++ .local/bin/surfmenu | 4 + .local/bin/tdout | 9 + .local/bin/test.sh | 9 + .local/bin/texclear | 32 +++ .local/bin/texinit | 6 + .local/bin/tmux-mpsyt | 16 ++ .local/bin/tmux-r | 18 ++ .local/bin/tmux-shell | 18 ++ .local/bin/tmux-vlc | 19 ++ .local/bin/todotable | 23 ++ .local/bin/trackpadtoggle | 15 ++ .local/bin/transadd | 9 + .local/bin/umountmenu | 42 ++++ .local/bin/unix | 25 +++ .local/bin/vifmrun | 16 ++ .local/bin/volumectl | 23 ++ .local/bin/vpnmenu | 14 ++ .local/bin/vpnstatus | 25 +++ .local/bin/websearch | 31 +++ .local/bin/wifi | 10 + .local/bin/yadms | 15 ++ 73 files changed, 2563 insertions(+) create mode 100755 .local/bin/Rinstall create mode 100755 .local/bin/aliasgen create mode 100755 .local/bin/bars create mode 100755 .local/bin/blocks create mode 100755 .local/bin/bloks create mode 100755 .local/bin/bonsai create mode 100755 .local/bin/camtoggle create mode 100755 .local/bin/colorbars create mode 100755 .local/bin/colorbars-sm create mode 100755 .local/bin/colorscheme create mode 100755 .local/bin/compiler create mode 100755 .local/bin/cronbat create mode 100755 .local/bin/crontog create mode 100755 .local/bin/datetime create mode 100755 .local/bin/define create mode 100755 .local/bin/displaymenu create mode 100755 .local/bin/displayselect create mode 100755 .local/bin/dna create mode 100755 .local/bin/dropbox-status create mode 100755 .local/bin/dropdowntoggle create mode 100755 .local/bin/dwmbar create mode 100755 .local/bin/dwmbar-battery create mode 100755 .local/bin/emoji-copy create mode 100755 .local/bin/extract create mode 100755 .local/bin/fixaudio create mode 100755 .local/bin/gd2pdf create mode 100755 .local/bin/getbib create mode 100755 .local/bin/groffdown create mode 100755 .local/bin/kblayout create mode 100755 .local/bin/layouttoggle create mode 100755 .local/bin/linkhandler create mode 100755 .local/bin/makestereo create mode 100755 .local/bin/manualgen create mode 100755 .local/bin/mountmenu create mode 100755 .local/bin/newsup create mode 100755 .local/bin/opout create mode 100755 .local/bin/pacman-colors create mode 100755 .local/bin/pipes create mode 100755 .local/bin/pipesx create mode 100755 .local/bin/pod-dl create mode 100755 .local/bin/podentr create mode 100755 .local/bin/powermenu create mode 100755 .local/bin/printermenu create mode 100755 .local/bin/qndl create mode 100755 .local/bin/queueandnotify create mode 100755 .local/bin/rain create mode 100755 .local/bin/recordmenu create mode 100755 .local/bin/rssadd create mode 100755 .local/bin/screenstatus create mode 100755 .local/bin/setbg create mode 100755 .local/bin/shortcutgen create mode 100755 .local/bin/slendy create mode 100755 .local/bin/surfmenu create mode 100755 .local/bin/tdout create mode 100755 .local/bin/test.sh create mode 100755 .local/bin/texclear create mode 100755 .local/bin/texinit create mode 100755 .local/bin/tmux-mpsyt create mode 100755 .local/bin/tmux-r create mode 100755 .local/bin/tmux-shell create mode 100755 .local/bin/tmux-vlc create mode 100755 .local/bin/todotable create mode 100755 .local/bin/trackpadtoggle create mode 100755 .local/bin/transadd create mode 100755 .local/bin/umountmenu create mode 100755 .local/bin/unix create mode 100755 .local/bin/vifmrun create mode 100755 .local/bin/volumectl create mode 100755 .local/bin/vpnmenu create mode 100755 .local/bin/vpnstatus create mode 100755 .local/bin/websearch create mode 100755 .local/bin/wifi create mode 100755 .local/bin/yadms (limited to '.local/bin') diff --git a/.local/bin/Rinstall b/.local/bin/Rinstall new file mode 100755 index 0000000..8d2857e --- /dev/null +++ b/.local/bin/Rinstall @@ -0,0 +1,5 @@ +#!/bin/sh +for f in $* + do + sudo R --vanilla -e "install.packages('"$f"', repos='http://cran.us.r-project.org')" +done diff --git a/.local/bin/aliasgen b/.local/bin/aliasgen new file mode 100755 index 0000000..bd351df --- /dev/null +++ b/.local/bin/aliasgen @@ -0,0 +1,14 @@ +#!/bin/sh + +# Removing unecessary comments and documentation +raw=$(cat $HOME/.config/aliasrc | tail -n +17 "$HOME/.config/aliasrc" | sed "s/^|\s*//g; + s/\(.*\)|\(.*\)|\(.*\)|/\1|\2|\3/g; + s/\s*$//g; + /^$/d") + +# #---zsh---# # +echo "$raw" | sed "s/^/alias\ /; + s/\s*|\s*/=\"/; + s/^.*-*+-*=\"$//; + s/\s*|$/\"/" > $HOME/.cache/zsh-aliases + diff --git a/.local/bin/bars b/.local/bin/bars new file mode 100755 index 0000000..0e671b6 --- /dev/null +++ b/.local/bin/bars @@ -0,0 +1,22 @@ +#!/usr/bin/bash + +# ANSI color scheme script by pfh +# Source: http://crunchbang.org/forums/viewtopic.php?pid=139126#p139126 +# Initializing mod by lolilolicon from Archlinux +# + +f=3 b=4 +for j in f b; do + for i in {0..7}; do + printf -v $j$i %b "\e[${!j}${i}m" + done +done +bld=$'\e[1m' +rst=$'\e[0m' +inv=$'\e[7m' + +cat << EOF + $f1▬▬▬▬▬ $f2▬▬▬▬▬ $f3▬▬▬▬▬ $f4▬▬▬▬▬ $f5▬▬▬▬▬ $f6▬▬▬▬▬ + $bld$f1▬▬▬▬▬ $f2▬▬▬▬▬ $f3▬▬▬▬▬ $f4▬▬▬▬▬ $f5▬▬▬▬▬ $f6▬▬▬▬▬ + $rst +EOF diff --git a/.local/bin/blocks b/.local/bin/blocks new file mode 100755 index 0000000..4e0ce6c --- /dev/null +++ b/.local/bin/blocks @@ -0,0 +1,3 @@ +#!/usr/bin/sh +pcs() { for i in {0..7}; do echo -en "\e[${1}$((30+$i))m \u2588\u2588 \e[0m"; done; } +printf "\n%s\n%s\n\n" "$(pcs)" "$(pcs '1;')" diff --git a/.local/bin/bloks b/.local/bin/bloks new file mode 100755 index 0000000..3f06d93 --- /dev/null +++ b/.local/bin/bloks @@ -0,0 +1,59 @@ +#!/usr/bin/sh + +# ANSI Color -- use these variables to easily have different color +# and format output. Make sure to output the reset sequence after +# colors (f = foreground, b = background), and use the 'off' +# feature for anything you turn on. + +initializeANSI() +{ + esc="" + + blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" + yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" + cyanf="${esc}[36m"; whitef="${esc}[37m" + + blackb="${esc}[1;30m"; redb="${esc}[1;31m"; greenb="${esc}[1;32m" + yellowb="${esc}[1;33m" blueb="${esc}[1;34m"; purpleb="${esc}[1;35m" + cyanb="${esc}[1;36m"; whiteb="${esc}[1;37m" + + boldon="${esc}[1m"; boldoff="${esc}[22m" + italicson="${esc}[3m"; italicsoff="${esc}[23m" + ulon="${esc}[4m"; uloff="${esc}[24m" + invon="${esc}[7m"; invoff="${esc}[27m" + + reset="${esc}[0m" +} + +# note in this first use that switching colors doesn't require a reset +# first - the new color overrides the old one. + +numbers (){ + +initializeANSI + +cat << EOF +${blackf}11111111${reset} ${redf}22222222${reset} ${greenf}33333333${reset} ${yellowf}44444444${reset} ${bluef}55555555${reset} ${purplef}66666666${reset} ${cyanf}77777777${reset} ${whitef}88888888${reset} +${blackb}11111111${reset} ${redb}22222222${reset} ${greenb}33333333${reset} ${yellowb}44444444${reset} ${blueb}55555555${reset} ${purpleb}66666666${reset} ${cyanb}77777777${reset} ${whiteb}88888888${reset} +EOF + +} + +blocks (){ + +initializeANSI + +cat << EOF +${blackf}████${reset}${blackb}████${reset} ${redf}████${reset}${redb}████${reset} ${greenf}████${reset}${greenb}████${reset} ${yellowf}████${reset}${yellowb}████${reset} ${bluef}████${reset}${blueb}████${reset} ${purplef}████${reset}${purpleb}████${reset} ${cyanf}████${reset}${cyanb}████${reset} ${whitef}████${reset}${whiteb}████${reset} +${blackf}████${reset}${blackb}████${reset} ${redf}████${reset}${redb}████${reset} ${greenf}████${reset}${greenb}████${reset} ${yellowf}████${reset}${yellowb}████${reset} ${bluef}████${reset}${blueb}████${reset} ${purplef}████${reset}${purpleb}████${reset} ${cyanf}████${reset}${cyanb}████${reset} ${whitef}████${reset}${whiteb}████${reset} +${blackf}████${reset}${blackb}████${reset} ${redf}████${reset}${redb}████${reset} ${greenf}████${reset}${greenb}████${reset} ${yellowf}████${reset}${yellowb}████${reset} ${bluef}████${reset}${blueb}████${reset} ${purplef}████${reset}${purpleb}████${reset} ${cyanf}████${reset}${cyanb}████${reset} ${whitef}████${reset}${whiteb}████${reset} +EOF + +} + +case $1 in + b) blocks;; + n) numbers;; + a) blocks && numbers;; + *) blocks && numbers;; +esac diff --git a/.local/bin/bonsai b/.local/bin/bonsai new file mode 100755 index 0000000..ce74ab3 --- /dev/null +++ b/.local/bin/bonsai @@ -0,0 +1,554 @@ +#!/usr/bin/env bash + +# I'm a bonsai-making machine! + +################################################# +## +# author: John Allbritten +# my website: theSynAck.com +# +# repo: https://gitlab.com/jallbrit +# script can be found in the bin/bin/fun folder. +# +# license: this script is published under GPLv3. +# I don't care what you do with it, but I do ask +# that you leave this message please! +# +# inspiration: http://andai.tv/bonsai/ +# andai's version was written in JS and served +# as the basis for this script. Originally, this +# was just a port. +## +################################################# + +# ------ vars ------ +# CLI options + +flag_h=false +live=false +infinite=false + +termCols=$(tput cols) +termRows=$(tput lines) +geometry="$((termCols - 1)),$termRows" + +leafchar='&' +termColors=false + +message="" +flag_m=false +basetype=1 +multiplier=5 + +lifeStart=28 +steptime=0.01 # time between steps + +# non-CLI options +lineWidth=4 # words per line + +# ------ parse options ------ + +OPTS="hlt:ig:c:Tm:b:M:L:" # the colon means it requires a value +LONGOPTS="help,live,time:,infinite,geo:,leaf:,termcolors,message:,base:,multiplier:,life:" + +parsed=$(getopt --options=$OPTS --longoptions=$LONGOPTS -- "$@") +eval set -- "${parsed[@]}" + +while true; do + case "$1" in + -h|--help) + flag_h=true + shift + ;; + + -l|--live) + live=true + shift + ;; + + -t|--time) + steptime="$2" + shift 2 + ;; + + -i|--infinite) + infinite=true + shift + ;; + + -g|--geo) + geo=$2 + shift 2 + ;; + + -c|--leaf) + leafchar="$2" + shift 2 + ;; + + -T|--termcolors) + termColors=true + shift + ;; + + -m|--message) + flag_m=true + message="$2" + shift 2 + ;; + + -b|--basetype) + basetype="$2" + shift 2 + ;; + + -M|--multiplier) + multiplier="$2" + shift 2 + ;; + + -L|--life) + lifeStart="$2" + shift 2 + ;; + + --) # end of arguments + shift + break + ;; + + *) + echo "error while parsing CLI options" + flag_h=true + ;; + esac +done + +HELP="Usage: bonsai [-h] [-i] [-l] [-T] [-m message] [-t time] + [-g x,y] [ -c char] [-M 0-9] + +bonsai.sh is a static and live bonsai tree generator, written in bash. + +optional args: + -l, --live enable live generation + -t, --time time time between each step of growth [default: 0.01] + -m, --message text attach a message to the tree + -b, --basetype 0-2 which ascii-art plant base to use (0 for none) [default: 1] + -i, --infinite keep generating trees until quit (2s between each) + -T, --termcolors use terminal colors + -g, --geo geo set custom geometry [default: fit to terminal] + -c, --leaf char character used for leaves [default: &] + -M, --multiplier 0-9 branch multiplier; higher equals more branching [default: 5] + -L, --life int life of tree; higher equals more overall growth [default: 28] + -h, --help show help" + +# check for help +$flag_h && echo -e "$HELP" && exit 0 + +# geometry processing +cols=$(echo "$geometry" | cut -d ',' -f1) # width; X +rows=$(echo "$geometry" | cut -d ',' -f2) # height; Y + +IFS=$'\n' # delimit strings by newline +tabs 4 # set tabs to 4 spaces + +declare -A gridMessage + +# message processing +if [ $flag_m = true ]; then + + messageWidth=20 + + # make room for the message to go on the right side + cols=$((cols - messageWidth - 8 )) + + # wordwrap message, delimiting by spaces + message="$(echo "$message" | fold -sw $messageWidth)" + + # get number of lines in the message + messageLineCount=0 + for line in $message; do + messageLineCount=$((messageLineCount + 1)) + done + + messageOffset=$((rows - messageLineCount - 7)) + + # put lines of message into a grid + index=$messageOffset + for line in $message; do + gridMessage[$index]="$line" + index=$((index + 1)) + done +fi + +# define colors +if [ $termColors = true ]; then + LightBrown='\e[1;33m' + DarkBrown='\e[0;33m' + BrownGreen='\e[1;32m' + Green='\e[0;32m' +else + LightBrown='\e[38;5;172m' + DarkBrown='\e[38;5;130m' + BrownGreen='\e[38;5;142m' + Green='\e[38;5;106m' +fi +Grey='\e[1;30m' +R='\e[0m' + +# create ascii base in lines +base="" +case $basetype in + 0) + base="" ;; + + 1) + width=15 + art="\ +${Grey}:${Green}___________${DarkBrown}./~~\\.${Green}___________${Grey}: + \\ / + \\________________________/ + (_) (_)" + ;; + + 2) + width=7 + art="\ +${Grey}(${Green}---${DarkBrown}./~~\\.${Green}---${Grey}) + ( ) + (________)" + ;; +esac + +# get base height +baseHeight=0 +for line in $art; do + baseHeight=$(( baseHeight + 1 )) +done + +# add spaces before base so that it's in the middle of the terminal +iter=1 +for line in $art; do + filler='' + for (( i=0; i < $(( (cols / 2) - width )); i++)); do + filler+=" " + done + base+="${filler}${line}" + [ $iter -ne $baseHeight ] && base+='\n' + iter=$((iter+1)) +done +unset IFS # reset delimiter + +rows=$((rows - baseHeight)) + +declare -A grid # must be done outside function for unknown reason + +trap 'echo "press q to quit"' SIGINT # disable CTRL+C + +init() { + branches=0 + shoots=0 + + branchesMax=$((multiplier * 110)) + shootsMax=$multiplier + + # fill grid full of spaces + for (( row=0; row < $rows; row++ )); do + for (( col=0; col < $cols; col++ )); do + grid[$row,$col]=' ' + done + done + + # No echo stdin and hide the cursor + if [ $live = true ]; then + stty -echo + echo -ne "\e[?25l" + + echo -ne "\e[2J" + fi +} + +grow() { + local start=$((cols / 2)) + + local x=$((cols / 2)) # start halfway across the screen + local y=$rows # start just above the base + + branch $x $y trunk $lifeStart +} + +branch() { + # argument declarations + local x=$1 + local y=$2 + local type=$3 + local life=$4 + local dx=0 + local dy=0 + + # check if the user is hitting q + timeout=0.001 + [ $live = "false" ] && timeout=.0001 + read -n 1 -t $timeout input + [ "$input" = "q" ] && clean "quit" + + branches=$((branches + 1)) + + # as long as we're alive... + while [ $life -gt 0 ]; do + + life=$((life - 1)) # ensure life ends + + # case $life in + # [0]) type=dead ;; + # [1-4]) type=dying ;; + # esac + + # set dy based on type + case $type in + shoot*) # if this is a shoot, trend horizontal/downward growth + case "$((RANDOM % 10))" in + [0-1]) dy=-1 ;; + [2-7]) dy=0 ;; + [8-9]) dy=1 ;; + esac + ;; + + dying) # discourage vertical growth + case "$((RANDOM % 10))" in + [0-1]) dy=-1 ;; + [2-8]) dy=0 ;; + [9-10]) dy=1 ;; + esac + ;; + + *) # otherwise, let it grow up/not at all + dy=0 + [ $life -ne $lifeStart ] && [ $((RANDOM % 10)) -gt 2 ] && dy=-1 + ;; + esac + # if we're about to hit the ground, cut it off + [ $dy -gt 0 ] && [ $y -gt $(( rows - 1 )) ] && dy=0 + [ $type = "trunk" ] && [ $life -lt 4 ] && dy=0 + + # set dx based on type + case $type in + shootLeft) # tend left: dx=[-2,1] + case $(( RANDOM % 10 )) in + [0-1]) dx=-2 ;; + [2-5]) dx=-1 ;; + [6-8]) dx=0 ;; + [9]) dx=1 ;; + esac ;; + + shootRight) # tend right: dx=[-1,2] + case $(( RANDOM % 10 )) in + [0-1]) dx=2 ;; + [2-5]) dx=1 ;; + [6-8]) dx=0 ;; + [9]) dx=-1 ;; + esac ;; + + dying) # tend left/right: dx=[-3,3] + dx=$(( (RANDOM % 7) - 3)) ;; + + *) # tend equal: dx=[-1,1] + dx=$(( (RANDOM % 3) - 1)) ;; + + esac + + # re-branch upon conditions + if [ $branches -lt $branchesMax ]; then + + # branch is dead + if [ $life -lt 3 ]; then + branch $x $y dead $life + + # branch is dying and needs to branch into leaves + elif [ $type = trunk ] && [ $life -lt $((multiplier + 2)) ]; then + branch $x $y dying $life + + elif [[ $type = "shoot"* ]] && [ $life -lt $((multiplier + 2)) ]; then + branch $x $y dying $life + + # re-branch if: not close to the base AND (pass a chance test OR be a trunk, not have too man shoots already, and not be about to die) + elif [[ $type = trunk && $life -lt $((lifeStart - 8)) \ + && ( $(( RANDOM % (16 - multiplier) )) -eq 0 \ + || ($type = trunk && $(( life % 5 )) -eq 0 && $life -gt 5) ) ]]; then + + # if a trunk is splitting and not about to die, chance to create another trunk + if [ $((RANDOM % 3)) -eq 0 ] && [ $life -gt 7 ]; then + branch $x $y trunk $life + + elif [ $shoots -lt $shootsMax ]; then + + # give the shoot some life + tmpLife=$(( life + multiplier - 2 )) + [ $tmpLife -lt 0 ] && tmpLife=0 + + # first shoot is randomly directed + if [ $shoots -eq 0 ]; then + tmpType=shootLeft + [ $((RANDOM % 2)) -eq 0 ] && tmpType=shootRight + + + # secondary shoots alternate from the first + else + case $tmpType in + shootLeft) # last shoot was left, shoot right + tmpType=shootRight ;; + shootRight) # last shoot was right, shoot left + tmpType=shootLeft ;; + esac + fi + branch $x $y $tmpType $tmpLife + shoots=$((shoots + 1)) + fi + fi + else # if we're past max branches but want to branch... + char='<>' + fi + + # implement dx,dy + x=$((x + dx)) + y=$((y + dy)) + + # choose color + case $type in + trunk|shoot*) + color=${DarkBrown} + [ $(( RANDOM % 4 )) -eq 0 ] && color=${LightBrown} + ;; + + dying) color=${BrownGreen} ;; + + dead) color=${Green} ;; + esac + + # choose branch character + case $type in + trunk) + if [ $dx -lt 0 ]; then + char='\\' + elif [ $dx -eq 0 ]; then + char='/|' + elif [ $dx -gt 0 ]; then + char='/' + fi + [ $dy -eq 0 ] && char='/~' # not growing + #[ $dy -lt 0 ] && char='/~' # growing + ;; + + # shoots tend to look horizontal + shootLeft) + case $dx in + [-3,-1]) char='\\|' ;; + [0]) char='/|' ;; + [1,3]) char='/' ;; + esac + #[ $dy -lt 0 ] && char='/~' # growing up + [ $dy -gt 0 ] && char='/' # growing down + [ $dy -eq 0 ] && char='\\_' # not growing + ;; + + shootRight) + case $dx in + [-3,-1]) char='\\|' ;; + [0]) char='/|' ;; + [1,3]) char='/' ;; + esac + #[ $dy -lt 0 ] && char='' # growing up + [ $dy -gt 0 ] && char='\\' # growing down + [ $dy -eq 0 ] && char='_/' # not growing + ;; + + #dead) + # #life=$((life + 1)) + # char="${leafchar}" + # [ $dx -lt -2 ] || [ $dx -gt 2 ] && char="${leafchar}${leafchar}" + # ;; + + esac + + # set leaf if needed + [ $life -lt 4 ] && char="${leafchar}" + + # uncomment for help debugging + #echo -e "$life:\t$x, $y: $char" + + # put character in grid + grid[$y,$x]="${color}${char}${R}" + + # if live, print what we have so far and let the user see it + if [ $live = true ]; then + print + sleep $steptime + fi + done +} + +print() { + # parse grid for output + output="" + for (( row=0; row < $rows; row++)); do + + line="" + + for (( col=0; col < $cols; col++ )); do + + # this prints a space at 0,0 and is necessary at the moment + [ $live = true ] && echo -ne "\e[0;0H " + + # grab the character from our grid + line+="${grid[$row,$col]}" + done + + # add our message + if [ $flag_m = true ]; then + # remove trailing whitespace before we add our message + line=$(sed -r 's/[ \t]*$//' <(printf "$line")) + line+=" \t${gridMessage[$row]}" + fi + + line="${line}\n" + + # end 'er with the ol' newline + output+="$line" + done + + # add the ascii-art base we generated earlier + output+="$base" + + # output, removing trailing whitespace + sed -r 's/[ \t]*$//' <(printf "$output") +} + +clean() { + # Show cursor and echo stdin + if [ $live = true ]; then + echo -ne "\e[?25h" + stty echo + fi + + echo "" # ensure the cursor resets to the next line + + # if we wanna quit + if [ "$1" = "quit" ]; then + trap SIGINT + exit 0 + fi +} + +bonsai() { + init + grow + print + clean +} + +bonsai + +while [ $infinite = true ]; do + sleep 2 + bonsai +done diff --git a/.local/bin/camtoggle b/.local/bin/camtoggle new file mode 100755 index 0000000..a71bdf7 --- /dev/null +++ b/.local/bin/camtoggle @@ -0,0 +1,4 @@ +#!/bin/sh + +mpv --no-cache --no-osc --no-input-default-bindings --input-conf=/dev/null --title=webcam $(ls /dev/video[0,4,6,8] | tail -n 1) +# mpv --no-cache --no-osc --no-input-default-bindings --input-conf=/dev/null --title=webcam $(ls /dev/video[0,2,4,6,8] | tail -n 1) diff --git a/.local/bin/colorbars b/.local/bin/colorbars new file mode 100755 index 0000000..4e3b8f7 --- /dev/null +++ b/.local/bin/colorbars @@ -0,0 +1,38 @@ +#!/bin/sh +# +# colorbars - smpte color bars in sh +# http://git.io/colorbars + +echo + +for y in $(seq 0 13); do + printf %s ' ' + for color in 7 3 6 2 5 1 4; do + tput setab ${color} + printf %s ' ' + done + tput sgr0 + echo +done + +for y in 0 1; do + printf %s ' ' + for color in 4 0 5 0 6 0 7; do + tput setab ${color} + printf %s ' ' + done + tput sgr0 + echo +done + +for y in $(seq 0 4); do + printf %s ' ' + for color in 4 4 4 4 4 7 7 7 7 7 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0; do + tput setab ${color} + printf %s ' ' + done + tput sgr0 + echo +done + +echo diff --git a/.local/bin/colorbars-sm b/.local/bin/colorbars-sm new file mode 100755 index 0000000..e8e0b9d --- /dev/null +++ b/.local/bin/colorbars-sm @@ -0,0 +1,35 @@ +#!/bin/sh +echo + +# mini smpte color bars +for y in $(seq 0 6); do + printf %s ' ' + for color in 7 3 6 2 5 1 4; do + tput setab ${color} + printf %s ' ' + done + tput sgr0 + echo +done + +for y in 0 1; do + printf %s ' ' + for color in 4 0 5 0 6 0 7; do + tput setab ${color} + printf %s ' ' + done + tput sgr0 + echo +done + +for y in $(seq 0 2); do + printf %s ' ' + for color in 4 4 4 4 4 7 7 7 7 7 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0; do + tput setab ${color} + printf %s ' ' + done + tput sgr0 + echo +done + +echo diff --git a/.local/bin/colorscheme b/.local/bin/colorscheme new file mode 100755 index 0000000..f2aa179 --- /dev/null +++ b/.local/bin/colorscheme @@ -0,0 +1,27 @@ +#!/bin/bash +# +# This file echoes a bunch of color codes to the +# terminal to demonstrate what's available. Each +# line is the color code of one forground color, +# out of 17 (default + 16 escapes), followed by a +# test use of that color on all nine background +# colors (default + 8 escapes). +# + +T='niX' # The test text + +echo -e "\n 40m 41m 42m 43m\ + 44m 45m 46m 47m"; + +for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \ + '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \ + ' 36m' '1;36m' ' 37m' '1;37m'; + do FG=${FGs// /} + echo -en " $FGs \033[$FG $T " + for BG in 40m 41m 42m 43m 44m 45m 46m 47m; + do echo -en "$EINS \033[$FG\033[$BG $T \033[0m"; + done + echo; +done +echo + diff --git a/.local/bin/compiler b/.local/bin/compiler new file mode 100755 index 0000000..5b4f8c4 --- /dev/null +++ b/.local/bin/compiler @@ -0,0 +1,40 @@ +#!/bin/sh +# This script will compile or run another finishing operation on a document. I +# have this script run via vim. +# +# Compiles .tex. groff (.mom, .ms), .rmd, .md. +# Opens .sent files as sent presentations. +# Runs scripts based on extention or shebang + +file=$(readlink -f "$1") +dir=$(dirname "$file") +base="${file%.*}" + +cd "$dir" || exit + +textype() { \ + command="pdflatex" + ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex" + $command --output-directory="$dir" "$base" && + grep -i addbibresource "$file" >/dev/null && + biber --input-directory "$dir" "$base" && + $command --output-directory="$dir" "$base" && + $command --output-directory="$dir" "$base" + } + +case "$file" in + *\.ms) refer -PS -e -p"$REFERBIB" "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; + *\.gd) groffdown "$file" | refer -PS -e "-p$REFERBIB" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; + # *\.gd) groffdown "$file" | refer -PS -e "$REFERBIB" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; + *\.mom) refer -PS -e -p"$REFERBIB" "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;; + *\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;; + *\.rnw) Rscript -e "knitr::knit2pdf('"$file"')" ;; + *\.tex) textype "$file" ;; + *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; + *config.h) make && sudo make install ;; + *\.c) cc "$file" -o "$base" && "$base" ;; + *\.py) python "$file" ;; + *\.go) go run "$file" ;; + *\.sent) setsid sent "$file" 2>/dev/null & ;; + *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; +esac diff --git a/.local/bin/cronbat b/.local/bin/cronbat new file mode 100755 index 0000000..c09ff42 --- /dev/null +++ b/.local/bin/cronbat @@ -0,0 +1,8 @@ +#!/bin/sh +# Notify me with notify-send if my battery is below 25%. +# You can set this to run via cron. + +[ "$(cat /sys/class/power_supply/BAT0/status)" = "Charging" ] && exit +[ "$(cat /sys/class/power_supply/BAT0/capacity)" -lt 25 ] && +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus && +notify-send -u critical "Battery critically low." diff --git a/.local/bin/crontog b/.local/bin/crontog new file mode 100755 index 0000000..93c2d30 --- /dev/null +++ b/.local/bin/crontog @@ -0,0 +1,5 @@ +#!/bin/sh +# Toggles all cronjobs off/on. +# Stores disabled crontabs in ~/.consaved until restored. + +([ -f ~/.config/cronsaved ] && crontab - < ~/.config/cronsaved && rm ~/.config/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > ~/.config/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.") diff --git a/.local/bin/datetime b/.local/bin/datetime new file mode 100755 index 0000000..e2198bd --- /dev/null +++ b/.local/bin/datetime @@ -0,0 +1,3 @@ +#!/bin/sh + +date +"  %a %b %d |  %H:%M " diff --git a/.local/bin/define b/.local/bin/define new file mode 100755 index 0000000..ac3c61f --- /dev/null +++ b/.local/bin/define @@ -0,0 +1,3 @@ +#!/bin/sh + +sdcv --color $1 | less diff --git a/.local/bin/displaymenu b/.local/bin/displaymenu new file mode 100755 index 0000000..38b2d9b --- /dev/null +++ b/.local/bin/displaymenu @@ -0,0 +1,73 @@ +#!/bin/sh + +# A UI for detecting and selecting all displays. +# Probes xrandr for connected displays and lets user select one to use. +# User may also select "manual selection" which opens arandr. +# I plan on adding a routine from multi-monitor setups later. + +twoscreen() { # If multi-monitor is selected and there are two screens. + + mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") + # Mirror displays using native resolution of external display and a scaled + # version for the internal display + if [ "$mirror" = "yes" ]; then + external=$(echo "$screens" | dmenu -i -p "Optimize resolution for") + internal=$(echo "$screens" | grep -v "$external") + + res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + + res_ext_x=$(echo $res_external | sed 's/x.*//') + res_ext_y=$(echo $res_external | sed 's/.*x//') + res_int_x=$(echo $res_internal | sed 's/x.*//') + res_int_y=$(echo $res_internal | sed 's/.*x//') + + scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l) + scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l) + + xrandr --output "$external" --auto --scale 1.0x1.0 \ + --output "$internal" --auto --same-as "$external" \ + --scale "$scale_x"x"$scale_y" + else + + primary=$(echo "$screens" | dmenu -i -p "Select primary display") + secondary=$(echo "$screens" | grep -v "$primary") + direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") + xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0 + fi + } + +morescreen() { # If multi-monitor is selected and there are more than two screens. + primary=$(echo "$screens" | dmenu -i -p "Select primary display") + secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display") + direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") + tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display") + xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto + } + +multimon() { # Multi-monitor handler. + case "$(echo "$screens" | wc -l)" in + 1) xrandr $(echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + 2) twoscreen ;; + *) morescreen ;; + esac ;} + +# Get all possible displays +allposs=$(xrandr -q | grep "connected") + +# Get all connected screens. +screens=$(echo "$allposs" | grep " connected" | awk '{print $1}') + +# Get user choice including multi-monitor and manual selection: +chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement") && +case "$chosen" in + "manual selection") arandr ; exit ;; + "multi-monitor") multimon ;; + *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; +esac + +# setbg # Fix background if screen size/arangement has changed. +remaps # Re-remap keys if keyboard added (for laptop bases) +pgrep -x dunst >/dev/null && killall dunst && setsid dunst & # Restart dunst to ensure proper location on screen diff --git a/.local/bin/displayselect b/.local/bin/displayselect new file mode 100755 index 0000000..c0e3479 --- /dev/null +++ b/.local/bin/displayselect @@ -0,0 +1,72 @@ +#!/bin/sh + +# A UI for detecting and selecting all displays. Probes xrandr for connected +# displays and lets user select one to use. User may also select "manual +# selection" which opens arandr. + +twoscreen() { # If multi-monitor is selected and there are two screens. + + mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") + # Mirror displays using native resolution of external display and a scaled + # version for the internal display + if [ "$mirror" = "yes" ]; then + external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:") + internal=$(echo "$screens" | grep -v "$external") + + res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + + res_ext_x=$(echo $res_external | sed 's/x.*//') + res_ext_y=$(echo $res_external | sed 's/.*x//') + res_int_x=$(echo $res_internal | sed 's/x.*//') + res_int_y=$(echo $res_internal | sed 's/.*x//') + + scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l) + scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l) + + xrandr --output "$external" --auto --scale 1.0x1.0 \ + --output "$internal" --auto --same-as "$external" \ + --scale "$scale_x"x"$scale_y" + else + + primary=$(echo "$screens" | dmenu -i -p "Select primary display:") + secondary=$(echo "$screens" | grep -v "$primary") + direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") + xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0 + fi + } + +morescreen() { # If multi-monitor is selected and there are more than two screens. + primary=$(echo "$screens" | dmenu -i -p "Select primary display:") + secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:") + direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") + tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:") + xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto + } + +multimon() { # Multi-monitor handler. + case "$(echo "$screens" | wc -l)" in + 1) xrandr $(echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + 2) twoscreen ;; + *) morescreen ;; + esac ;} + +# Get all possible displays +allposs=$(xrandr -q | grep "connected") + +# Get all connected screens. +screens=$(echo "$allposs" | grep " connected" | awk '{print $1}') + +# Get user choice including multi-monitor and manual selection: +chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") && +case "$chosen" in + "manual selection") arandr ; exit ;; + "multi-monitor") multimon ;; + *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; +esac + +setbg # Fix background if screen size/arangement has changed. +remaps # Re-remap keys if keyboard added (for laptop bases) +pgrep -x dunst >/dev/null && killall dunst && setsid dunst & # Restart dunst to ensure proper location on screen diff --git a/.local/bin/dna b/.local/bin/dna new file mode 100755 index 0000000..a049e0b --- /dev/null +++ b/.local/bin/dna @@ -0,0 +1,46 @@ +#!/bin/bash +# +# ANSI color scheme script by pfh +# +# Initializing mod by lolilolicon from Archlinux +# + +f=3 b=4 +for j in f b; do + for i in {0..7}; do + printf -v $j$i %b "\e[${!j}${i}m" + done +done +bld=$'\e[1m' +rst=$'\e[0m' +inv=$'\e[7m' + +cat << EOF + + ${f1} █-----${bld}█ ${rst}${f2} █-----${bld}█${rst} ${f3} █-----${bld}█${rst} ${f4} █-----${bld}█${rst} ${f5} █-----${bld}█${rst} ${f6} █-----${bld}█${rst} + ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} + ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} + ${f1} █${rst} ${f2} █${rst} ${f3} █${rst} ${f4} █${rst} ${f5} █${rst} ${f6} █${rst} + ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █_${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} + ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} + ${f1}${bld} █-----${rst}${f1}█${rst} ${f2}${bld} █-----${rst}${f2}█${rst} ${f3}${bld} █-----${rst}${f3}█${rst} ${f4}${bld} █-----${rst}${f4}█${rst} ${f5}${bld} █-----${rst}${f5}█${rst} ${f6}${bld} █-----${rst}${f6}█${rst} + ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} + ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █-${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} + ${f1}${bld} █${rst} ${f2}${bld} █${rst} ${f3}${bld}█${rst} ${f4}${bld} █${rst} ${f5}${bld} █${rst} ${f6}${bld} █${rst} + ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} + ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} + ${f1} █-----${bld}█ ${rst}${f2} █-----${bld}█${rst} ${f3} █-----${bld}█${rst} ${f4} █-----${bld}█${rst} ${f5} █-----${bld}█${rst} ${f6} █-----${bld}█${rst} + ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} + ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} + ${f1} █${rst} ${f2}█${rst} ${f3} █${rst} ${f4} █${rst} ${f5} █${rst} ${f6} █${rst} + ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █_${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} + ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} + ${f1}${bld} █-----${rst}${f1}█${rst} ${f2}${bld} █-----${rst}${f2}█${rst} ${f3}${bld} █-----${rst}${f3}█${rst} ${f4}${bld} █-----${rst}${f4}█${rst} ${f5}${bld} █-----${rst}${f5}█${rst} ${f6}${bld} █-----${rst}${f6}█${rst} + ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} + ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █-${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} + ${f1}${bld} █${rst} ${f2}${bld} █${rst} ${f3}${bld} █${rst} ${f4}${bld} █${rst} ${f5}${bld} █${rst} ${f6}${bld} █${rst} + ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} + ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} + ${f1} █-----${bld}█ ${rst}${f2} █-----${bld}█${rst} ${f3} █-----${bld}█${rst} ${f4} █-----${bld}█${rst} ${f5} █-----${bld}█${rst} ${f6} █-----${bld}█${rst} + +EOF \ No newline at end of file diff --git a/.local/bin/dropbox-status b/.local/bin/dropbox-status new file mode 100755 index 0000000..05e6fda --- /dev/null +++ b/.local/bin/dropbox-status @@ -0,0 +1,9 @@ +#!/bin/sh + +case "$(dropbox-cli status | head -n 1)" in + "Up to date") icon="" ;; + "Syncing"*) icon=" " ;; + *) icon=" " +esac + +echo " $icon " diff --git a/.local/bin/dropdowntoggle b/.local/bin/dropdowntoggle new file mode 100755 index 0000000..056a716 --- /dev/null +++ b/.local/bin/dropdowntoggle @@ -0,0 +1,17 @@ +#!/bin/sh + +# Toggle dropdown terminal windows. +# The first argument is the title of the window. +# The rest of it is the program/command to be run +# in the dropdown window. + +class="$1" +title="dropdown_$class" +active="$(xdotool search --name $title | wc -l)" +shift + + +case "$active" in + 0) $TERMINAL -c "dropdown" -t "$class" -e "$@" & ;; + *) kill -9 `xdotool search --name "$class" getwindowpid` ;; +esac diff --git a/.local/bin/dwmbar b/.local/bin/dwmbar new file mode 100755 index 0000000..a322665 --- /dev/null +++ b/.local/bin/dwmbar @@ -0,0 +1,26 @@ +#!/bin/sh + +# Refreshes the dwm bar using the scripts in: +# $SCRIPTS/dwm/ + +# When given the echo option, echo to stdout instead +# of refreshing (useful for debugging) + +battery=$(battery) +datetime=$(datetime) +# dropbox=$(dropbox-status) +kblayout=$(kblayout) +# mailbox=$(mailbox) +news=$(news) +vpnstatus=$(vpnstatus) +# wifi=$(wifi) +yadms=$(yadms) + +bar="$yadms|$news|$datetime|$kblayout|$vpnstatus|$battery |" + +case "$1" in + echo) echo "$bar" ;; + *) xsetroot -name "$bar" ;; +esac + + diff --git a/.local/bin/dwmbar-battery b/.local/bin/dwmbar-battery new file mode 100755 index 0000000..bb2b76e --- /dev/null +++ b/.local/bin/dwmbar-battery @@ -0,0 +1,22 @@ +#!/bin/sh +# Better battery manager for polybar + +# Charging:  +# Discharching:  +# Full: underscore:  +# LOW BATTERY:  + +batstatus=$(acpi | tail -n 1) + +ico="" + +# Change the underscore color according to the charging state +case "$batstatus" in + *Charging*) ico=" ";; + *Discharging*) ico="  " ;; + *) ico="  " ;; +esac + +percentage=$( echo "$batstatus" | sed "s/.*\(\ [0-9]*\)\%.*$/\1/; s/\ //g; 1q") + +echo "$ico $percentage%" diff --git a/.local/bin/emoji-copy b/.local/bin/emoji-copy new file mode 100755 index 0000000..a52c171 --- /dev/null +++ b/.local/bin/emoji-copy @@ -0,0 +1,20 @@ +#!/bin/sh + +# Runs a prompt to choose an emoji to copy +# to the clipboard. Some font-awesome icons are +# also supported. + +choice=$( cat $SCRIPTS/utilities/.emoji-list.txt | dmenu -i -p "Emojis & Font Awesome") + +icon=$(echo $choice | sed "s/\(.\).*$/\1/") +label=$(echo $choice | sed "s/^..\(.*\)/\1/") + +printf $icon | xsel -b + +echo "$icon" + +if [[ "$icon" == "" ]]; then + notify-send "Operation Cancelled" +else + notify-send -i "$HOME/.fonts/svgs/$label.svg" "Clipboard:" "$label has been copied!" +fi diff --git a/.local/bin/extract b/.local/bin/extract new file mode 100755 index 0000000..3258d2a --- /dev/null +++ b/.local/bin/extract @@ -0,0 +1,41 @@ +#!/bin/sh +# A general, all-purpose extraction script. +# +# Default behavior: Extract archive into new directory +# Behavior with `-c` option: Extract contents into current directory + +while getopts "hc" o; do case "${o}" in + c) extracthere="True" ;; + *) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit ;; +esac done + +if [ -z "$extracthere" ]; then + archive="$(readlink -f "$*")" && + directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" && + mkdir -p "$directory" && + cd "$directory" || exit +else + archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)")" +fi + +[ "$archive" = "" ] && printf "Give archive to extract as argument.\\n" && exit + +if [ -f "$archive" ] ; then + case "$archive" in + *.tar.bz2|*.tar.xz|*.tbz2) tar xvjf "$archive" ;; + *.tar.gz|*.tgz) tar xvzf "$archive" ;; + *.lzma) unlzma "$archive" ;; + *.bz2) bunzip2 "$archive" ;; + *.rar) unrar x -ad "$archive" ;; + *.gz) gunzip "$archive" ;; + *.tar) tar xvf "$archive" ;; + *.zip) unzip "$archive" ;; + *.Z) uncompress "$archive" ;; + *.7z|*.xpi) 7z x "$archive" ;; + *.xz) unxz "$archive" ;; + *.exe) cabextract "$archive" ;; + *) printf "extract: '%s' - unknown archive method\\n" "$archive" ;; + esac +else + printf "File \"%s\" not found.\\n" "$archive" +fi diff --git a/.local/bin/fixaudio b/.local/bin/fixaudio new file mode 100755 index 0000000..699218a --- /dev/null +++ b/.local/bin/fixaudio @@ -0,0 +1,8 @@ +#!bin/sh + +base=$(basename "$1") +ext="${base##*.}" +base="${base%.*}" +# ffmpeg -i "$1" -itsoffset 0.350 -i "$1" -c:v h264 -c:a aac -map 0:0 -map 1:1 "$base"_synced."ext" && \ +ffmpeg -i "$1" -itsoffset 0.250 -i "$1" -map 0:v -map 1:a -c copy "$base"_synced."$ext" && \ +notify-send -i "/home/master/.fonts/svg/headphones.svg" "Audio synced" diff --git a/.local/bin/gd2pdf b/.local/bin/gd2pdf new file mode 100755 index 0000000..057f13a --- /dev/null +++ b/.local/bin/gd2pdf @@ -0,0 +1,3 @@ +#!/bin/sh + +groffdown "$1" | refer -PS -e -p"$REFERBIB" | groff -me -ms -kejpt -T pdf | zathura - diff --git a/.local/bin/getbib b/.local/bin/getbib new file mode 100755 index 0000000..ed441c5 --- /dev/null +++ b/.local/bin/getbib @@ -0,0 +1,14 @@ +#!/bin/sh +[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit + +if [ -f "$1" ]; then + # Try to get DOI from pdfinfo or pdftotext output. + doi=$(pdfinfo "$1" | grep -io "doi:.*") || + doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) || + exit 1 +else + doi="$1" +fi + +# Check crossref.org for the bib citation. +curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n" diff --git a/.local/bin/groffdown b/.local/bin/groffdown new file mode 100755 index 0000000..f2810a5 --- /dev/null +++ b/.local/bin/groffdown @@ -0,0 +1,54 @@ +#!/bin/bash + +file=$(readlink -f "$1") +dir=$(dirname "$file") +base="${file%.*}" + +output=$( sed -e '1,1d + s/title:/\.TL\n/ + s/author:/\.AU\n/ + s/date:/\.ND\n/ + s/institution:/\.AI\n/ + + s/\\begin{abstract}/\.AB/ + s/\\end{abstract}/\.AE/ + + s/^\#####.\(.*\)/\.NH 5\n\1\n\.PP/g + s/^\####.\(.*\)/\.NH 4\n\1\n\.PP/g + s/^\###.\(.*\)/\.NH 3\n\1\n\.PP/g + s/^\##.\(.*\)/\.NH 2\n\1\n\.PP/g + s/^\#.\(.*\)/\.NH 1\n\1\n\.PP/g + + s/\*\*\*\(.*\)\*\*\*$/\n\.BI\ \"\1\"\ /g + s/\*\*\*\(.*\)\*\*\*\(.\)$/\n\.BI\ \"\1\"\ \"\2\"/g + s/\*\*\*\(.*\)\*\*\*\(.\)/\n\.BI\ \"\1\"\ \"\2\"\n/g + + s/\*\*\(.*\)\*\*$/\n\.B\ \"\1\"\ /g + s/\*\*\(.*\)\*\*\(.\)$/\n\.B\ \"\1\"\ \"\2\"/g + s/\*\*\(.*\)\*\*\(.\)/\n\.B\ \"\1\"\ \"\2\"\n/g + + s/\*\(.*\)\*$/\n\.I\ \"\1\"\ /g + s/\*\(.*\)\*\(.\)$/\n\.I\ \"\1\"\ \"\2\"/g + s/\*\(.*\)\*\(.\)/\n\.I\ \"\1\"\ \"\2\"\n/g + + s/`\(.*\)`$/\n\.CW\ \"\1\"\ /g + s/`\(.*\)`\(.\)$/\n\.CW\ \"\1\"\ \"\2\"/g + s/`\(.*\)`\(.\)/\n\.CW\ \"\1\"\ \"\2\"\n/g + + s/^\ ...............-\ /.IP\ \\(bu\ 10\n/g + s/^\ ...........-\ /.IP\ \\(bu\ 8\n/g + s/^\ .......-\ /.IP\ \\(bu\ 6\n/g + s/^\ ...-\ /.IP\ \\(bu\ 4\n/g + s/^-\ /.IP\ \\(bu\ 2\n/g + s/^\ .*-\ /.IP\ \\(bu\ 12\n/g + + ' $1) +# echo "$output" | groff -me -ms -kejpt -T pdf > $base.pdf + +# echo "$output" > $base.ms +# groff -ms $base.ms -T pdf > $base.pdf + +echo "$output" + +# $output >> output.ms +# s/\*\*\*.*\*\*\*/Hi\1hi/g diff --git a/.local/bin/kblayout b/.local/bin/kblayout new file mode 100755 index 0000000..3cd1132 --- /dev/null +++ b/.local/bin/kblayout @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "  $(cat $HOME/.cache/layout) " diff --git a/.local/bin/layouttoggle b/.local/bin/layouttoggle new file mode 100755 index 0000000..4742080 --- /dev/null +++ b/.local/bin/layouttoggle @@ -0,0 +1,24 @@ +#!/bin/sh + +layout=$(cat $HOME/.cache/layout) + +case "$layout" in + ca) setxkbmap -model pc104 -layout us -variant ,, + echo us > $HOME/.cache/layout + # pkill -RTMIN+46 dwmblocks + $SCRIPTS/cron/dwmbar + ;; + us) setxkbmap -model pc104 -layout ca -variant ,, + echo ca > $HOME/.cache/layout + # pkill -RTMIN+46 dwmblocks + $SCRIPTS/cron/dwmbar + ;; + *) setxkbmap -model pc104 -layout us -variant ,, + echo us > $HOME/.cache/layout + # pkill -RTMIN+46 dwmblocks + $SCRIPTS/cron/dwmbar + ;; + esac + +# [[ "$layout" == "us" ]] && setxkbmap -model pc104 -layout ca -variant ,, ; echo ca > $HOME/.cache/layout && $SCRIPTS/cron/dwmbar +# [[ "$layout" == "us" ]] || setxkbmap -model pc104 -layout ca -variant ,, ; echo ca > $HOME/.cache/layout && $SCRIPTS/cron/dwmbar diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler new file mode 100755 index 0000000..8b8ca76 --- /dev/null +++ b/.local/bin/linkhandler @@ -0,0 +1,22 @@ +#!/bin/sh + +# Feed script a url or file location. +# If an image, it will view in sxiv, +# if a video or gif, it will view in mpv +# if a music file or pdf, it will download, +# otherwise it opens link in browser. + +# If no url given. Opens browser. For using script as $BROWSER. +[ -z "$1" ] && { "$BROWSER"; exit; } + +case "$1" in + *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*) + setsid -f mpv --no-config "$1" ;; + *png|*jpg|*jpe|*jpeg|*gif|*.webp) + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;; + *mp3|*flac|*opus|*mp3?source*) + setsid -f tsp curl -LO "$1" >/dev/null 2>&1 ;; + *) + if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1" + else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;; +esac diff --git a/.local/bin/makestereo b/.local/bin/makestereo new file mode 100755 index 0000000..f43a696 --- /dev/null +++ b/.local/bin/makestereo @@ -0,0 +1,9 @@ +#!/bin/sh + +file=$(readlink -f "$1") +dir=$(dirname "$file") +base="${file##*/}" +ext="${base##*.}" + +ffmpeg -i $file -af "pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR" "$dir/stereo-$base.$ext" + diff --git a/.local/bin/manualgen b/.local/bin/manualgen new file mode 100755 index 0000000..738ef5c --- /dev/null +++ b/.local/bin/manualgen @@ -0,0 +1,19 @@ +#!/bin/sh + +config=$(cat $HOME/.config/sxhkd/sxhkdrc | sed " +s/^\s.*//g; +s/^#\s.*//; +s/^##\s/##\n-\ \*\*/; +s/#-#\s*/##\n-->/; +s/\s*#-#$/\n##/; +/^$/d" | awk '/##/{if (x)print x;x="";next}{x=(!x)?$0:x"**:`"$0;}STOP{print x;}' | + sed "s/-->/##\ /; + s/:\(.*\)$/:\1\`/; + s/\s+\s/+/g; + s/#\*\*:.*//") + +manual=$(cat $HOME/.config/manual.part) + +printf " $manual \n $config" | gd2pdf + +# printf " $manual \n $config" diff --git a/.local/bin/mountmenu b/.local/bin/mountmenu new file mode 100755 index 0000000..6a48c0e --- /dev/null +++ b/.local/bin/mountmenu @@ -0,0 +1,61 @@ +#!/bin/sh +# Gives a dmenu prompt to mount unmounted drives. +# If they're in /etc/fstab, they'll be mounted automatically. +# Otherwise, you'll be prompted to give a mountpoint from already existsing directories. +# If you input a novel directory, it will prompt you to create that directory. + +getmount() { \ + [ -z "$chosen" ] && exit 1 + mp="$(find $1 | dmenu -i -l 20 -p "Type in mount point")" + [ "$mp" = "" ] && exit 1 + if [ ! -d "$mp" ]; then + mkdiryn=$(printf "No\\nYes" | dmenu -i -l 2 -p "$mp does not exist. Create it?") + [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") + fi + } + +mountusb() { \ + chosen="$(echo "$usbdrives" | dmenu -i -l 20 -p "Mount which drive?" | awk '{print $1}')" + sudo -A mount "$chosen" && notify-send -i "$HOME/.fonts/svg/usb.svg" -a "USB mounting" "$chosen mounted." && exit 0 + alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/games|\/home$|SWAP/&&length($3)>1{printf "-not \( -path *%s -prune \) \ \n",$3}') + getmount "/mnt /mount $HOME/Drives/Usb1 $HOME/Drives/Usb2 $HOME/Drives/Usb3 -type d $alreadymounted" + partitiontype="$(lsblk -no "fstype" "$chosen")" + case "$partitiontype" in + "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; + *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" 741 "$mp";; + esac + notify-send -i "$HOME/.fonts/svg/usb.svg" -a "USB mounting" "$chosen mounted to $mp." + } + +mountandroid() { \ + chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1) + getmount "$HOME -maxdepth 3 -type d" + simple-mtpfs --device "$chosen" "$mp" + notify-send -i "$HOME/.fonts/svg/android.svg" -a "Android Mounting + Android device mounted to $mp." + } + +asktype() { \ + case $(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?") in + USB) mountusb ;; + Android) mountandroid ;; + esac + } + +anddrives=$(simple-mtpfs -l 2>/dev/null) +usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}' | sed 's/^.*1M.*$//; /^$/d')" +echo $usbdrives + +if [ -z "$usbdrives" ]; then + [ -z "$anddrives" ] && notify-send -i "~/.fonts/svg/usb.svg" -a "USB Mounting" "No USB drive or Android device detected" && exit + echo "Android device(s) detected." + mountandroid +else + if [ -z "$anddrives" ]; then + echo "USB drive(s) detected." + mountusb + else + echo "Mountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.local/bin/newsup b/.local/bin/newsup new file mode 100755 index 0000000..2f47b6f --- /dev/null +++ b/.local/bin/newsup @@ -0,0 +1,15 @@ +#!/bin/sh +# Set as a cron job to check for new RSS entries for newsboat. +# If newsboat is open, sends it an "R" key to refresh. + +ping -q -c 1 1.1.1.1 > /dev/null || exit + +/usr/bin/notify-send -t 1 -i "$HOME/.fonts/svg/rss.svg" -a RSS "Updating RSS feeds..." + +pgrep -x newsboat >/dev/null && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit + +echo "" > /tmp/newsupdate && dwmbar +pkill -RTMIN+6 i3blocks +/usr/bin/newsboat -x reload +rm -f /tmp/newsupdate +/usr/bin/notify-send -t 1 -i "$HOME/.fonts/svg/rss.svg" -a RSS "RSS feed update complete." && dwmbar diff --git a/.local/bin/opout b/.local/bin/opout new file mode 100755 index 0000000..2c61400 --- /dev/null +++ b/.local/bin/opout @@ -0,0 +1,11 @@ +#!/bin/sh +# opout: "open output": A general handler for opening a file's intended output. +# I find this useful especially running from vim. + +basename="$(echo "$1" | sed 's/\.[^\/.]*$//')" + +case "$1" in + *.tex|*.rnw|*.gd|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;; + *.html) setsid "$BROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;; + *.sent) setsid sent "$1" >/dev/null 2>&1 & ;; +esac diff --git a/.local/bin/pacman-colors b/.local/bin/pacman-colors new file mode 100755 index 0000000..2b54b07 --- /dev/null +++ b/.local/bin/pacman-colors @@ -0,0 +1,48 @@ +#!/bin/bash +# +# ANSI color scheme script featuring PACMAN +# by pfh +# +# Initializing procedure by lolilolicon +# + +f=3 b=4 +for j in f b; do + for i in {0..7}; do + printf -v $j$i %b "\e[${!j}${i}m" + done +done +bld=$'\e[1m' +rst=$'\e[0m' +inv=$'\e[7m' + + +cat << EOF + +$rst + $f3 ▄███████▄ $f1 ▄██████▄ $f2 ▄██████▄ $f4 ▄██████▄ $f5 ▄██████▄ $f6 ▄██████▄ + $f3▄█████████▀▀ $f1▄$f7█▀█$f1██$f7█▀█$f1██▄ $f2▄█$f7█ █$f2██$f7█ █$f2█▄ $f4▄█$f7█ █$f4██$f7█ █$f4█▄ $f5▄█$f7█ █$f5██$f7█ █$f5█▄ $f6▄██$f7█▀█$f6██$f7█▀█$f6▄ + $f3███████▀ $f7▄▄ ▄▄ ▄▄ $f1█$f7▄▄█$f1██$f7▄▄█$f1███ $f2██$f7███$f2██$f7███$f2██ $f4██$f7███$f4██$f7███$f4██ $f5██$f7███$f5██$f7███$f5██ $f6███$f7█▄▄$f6██$f7█▄▄$f6█ + $f3███████▄ $f7▀▀ ▀▀ ▀▀ $f1████████████ $f2████████████ $f4████████████ $f5████████████ $f6████████████ + $f3▀█████████▄▄ $f1██▀██▀▀██▀██ $f2██▀██▀▀██▀██ $f4██▀██▀▀██▀██ $f5██▀██▀▀██▀██ $f6██▀██▀▀██▀██ + $f3 ▀███████▀ $f1▀ ▀ ▀ ▀ $f2▀ ▀ ▀ ▀ $f4▀ ▀ ▀ ▀ $f5▀ ▀ ▀ ▀ $f6▀ ▀ ▀ ▀ +$rst +EOF + +# $rst +# $f3 ▄███████▄ $f1 ▄██████▄ $f2 ▄██████▄ $f4 ▄██████▄ $f5 ▄██████▄ $f6 ▄██████▄ +# $f3▄█████████▀▀ $f1▄$f7█▀█$f1██$f7█▀█$f1██▄ $f2▄█$f7███$f2██$f7███$f2█▄ $f4▄█$f7███$f4██$f7███$f4█▄ $f5▄█$f7███$f5██$f7███$f5█▄ $f6▄██$f7█▀█$f6██$f7█▀█$f6▄ +# $f3███████▀ $f7▄▄ ▄▄ ▄▄ $f1█$f7▄▄█$f1██$f7▄▄█$f1███ $f2██$f7█ █$f2██$f7█ █$f2██ $f4██$f7█ █$f4██$f7█ █$f4██ $f5██$f7█ █$f5██$f7█ █$f5██ $f6███$f7█▄▄$f6██$f7█▄▄$f6█ +# $f3███████▄ $f7▀▀ ▀▀ ▀▀ $f1████████████ $f2████████████ $f4████████████ $f5████████████ $f6████████████ +# $f3▀█████████▄▄ $f1██▀██▀▀██▀██ $f2██▀██▀▀██▀██ $f4██▀██▀▀██▀██ $f5██▀██▀▀██▀██ $f6██▀██▀▀██▀██ +# $f3 ▀███████▀ $f1▀ ▀ ▀ ▀ $f2▀ ▀ ▀ ▀ $f4▀ ▀ ▀ ▀ $f5▀ ▀ ▀ ▀ $f6▀ ▀ ▀ ▀ +# $bld +# $f3 ▄███████▄ $f1 ▄██████▄ $f2 ▄██████▄ $f4 ▄██████▄ $f5 ▄██████▄ $f6 ▄██████▄ +# $f3▄█████████▀▀ $f1▄$f7█▀█$f1██$f7█▀█$f1██▄ $f2▄█$f7█ █$f2██$f7█ █$f2█▄ $f4▄█$f7█ █$f4██$f7█ █$f4█▄ $f5▄█$f7█ █$f5██$f7█ █$f5█▄ $f6▄██$f7█▀█$f6██$f7█▀█$f6▄ +# $f3███████▀ $f7▄▄ ▄▄ ▄▄ $f1█$f7▄▄█$f1██$f7▄▄█$f1███ $f2██$f7███$f2██$f7███$f2██ $f4██$f7███$f4██$f7███$f4██ $f5██$f7███$f5██$f7███$f5██ $f6███$f7█▄▄$f6██$f7█▄▄$f6█ +# $f3███████▄ $f7▀▀ ▀▀ ▀▀ $f1████████████ $f2████████████ $f4████████████ $f5████████████ $f6████████████ +# $f3▀█████████▄▄ $f1██▀██▀▀██▀██ $f2██▀██▀▀██▀██ $f4██▀██▀▀██▀██ $f5██▀██▀▀██▀██ $f6██▀██▀▀██▀██ +# $f3 ▀███████▀ $f1▀ ▀ ▀ ▀ $f2▀ ▀ ▀ ▀ $f4▀ ▀ ▀ ▀ $f5▀ ▀ ▀ ▀ $f6▀ ▀ ▀ ▀ +# $rst +# EOF + diff --git a/.local/bin/pipes b/.local/bin/pipes new file mode 100755 index 0000000..4709745 --- /dev/null +++ b/.local/bin/pipes @@ -0,0 +1,136 @@ +#!/usr/bin/env bash +# pipes.sh: Animated pipes terminal screensaver. +# +# This modified version is maintained at: +# +# https://github.com/pipeseroni/pipes.sh + +VERSION=1.2.0 + +M=32768 +p=1 +f=75 s=13 r=2000 t=0 +w=80 h=24 + +resize() { + w=$(tput cols) h=$(tput lines) +} + +# ab -> idx = a*4 + b +# 0: up, 1: right, 2: down, 3: left +# 00 means going up , then going up -> ┃ +# 12 means going right, then going down -> ┓ +sets=( + "┃┏ ┓┛━┓ ┗┃┛┗ ┏━" + "│╭ ╮╯─╮ ╰│╯╰ ╭─" + "│┌ ┐┘─┐ └│┘└ ┌─" + "║╔ ╗╝═╗ ╚║╝╚ ╔═" + "|+ ++-+ +|++ +-" + "|/ \/-\ \|/\ /-" + ".. .... .... .." + ".o oo.o o.oo o." + "-\ /\|/ /-\/ \|" # railway + "╿┍ ┑┚╼┒ ┕╽┙┖ ┎╾" # knobby pipe +) +v=() +RNDSTART=0 +BOLD=1 +NOCOLOR=0 + +OPTIND=1 +while getopts "p:t:f:s:r:RBChv" arg; do +case $arg in + p) ((p=(OPTARG>0)?OPTARG:p));; + t) + if [[ "$OPTARG" = c???????????????? ]]; then + V+=(${#sets[@]}) + sets+=("${OPTARG:1}") + else + ((OPTARG>=0 && OPTARG<${#sets[@]})) && V+=($OPTARG) + fi + ;; + f) ((f=(OPTARG>19 && OPTARG<101)?OPTARG:f));; + s) ((s=(OPTARG>4 && OPTARG<16 )?OPTARG:s));; + r) ((r=(OPTARG>=0)?OPTARG:r));; + R) RNDSTART=1;; + B) BOLD=0;; + C) NOCOLOR=1;; + h) echo -e "Usage: $(basename $0) [OPTION]..." + echo -e "Animated pipes terminal screensaver.\n" + echo -e " -p [1-]\tnumber of pipes (D=1)." + echo -e " -t [0-$((${#sets[@]} - 1))]\ttype of pipes, can be used more than once (D=0)." + echo -e " -t c[16 chars]\tcustom type of pipes." + echo -e " -f [20-100]\tframerate (D=75)." + echo -e " -s [5-15]\tprobability of a straight fitting (D=13)." + echo -e " -r LIMIT\treset after x characters, 0 if no limit (D=2000)." + echo -e " -R \t\trandom starting point." + echo -e " -B \t\tno bold effect." + echo -e " -C \t\tno color." + echo -e " -h\t\thelp (this screen)." + echo -e " -v\t\tprint version number.\n" + exit 0;; + v) echo "$(basename -- "$0") $VERSION" + exit 0 + esac +done + +# set default values if not by options +((${#V[@]})) || V=(0) + +cleanup() { + # clear up standard input + read -t 0.001 && cat /dev/null + + # terminal has no smcup and rmcup capabilities + ((FORCE_RESET)) && reset && exit 0 + + tput rmcup + tput cnorm + stty echo + ((NOCOLOR)) && echo -ne '\x1b[0m' + exit 0 +} +trap resize SIGWINCH +trap cleanup HUP TERM +trap 'break 2' INT + +resize + +for (( i=1; i<=p; i++ )); do + c[i]=$((i%8)) n[i]=0 l[i]=0 + ((x[i]=RNDSTART==1?RANDOM*w/32768:w/2)) + ((y[i]=RNDSTART==1?RANDOM*h/32768:h/2)) + v[i]=${V[${#V[@]} * RANDOM / M]} +done + +stty -echo +tput smcup || FORCE_RESET=1 +tput civis +tput clear +# any key press exits the loop and this script +while REPLY=; read -t 0.0$((1000/f)) -n 1 2>/dev/null; [[ -z $REPLY ]] ; do + for (( i=1; i<=p; i++ )); do + # New position: + ((${l[i]}%2)) && ((x[i]+=-${l[i]}+2,1)) || ((y[i]+=${l[i]}-1)) + + # Loop on edges (change color on loop): + ((${x[i]}>=w||${x[i]}<0||${y[i]}>=h||${y[i]}<0)) && ((c[i]=RANDOM%8, v[i]=V[${#V[@]}*RANDOM/M])) + ((x[i]=(x[i]+w)%w)) + ((y[i]=(y[i]+h)%h)) + + # New random direction: + ((n[i]=RANDOM%s-1)) + ((n[i]=(${n[i]}>1||${n[i]}==0)?${l[i]}:${l[i]}+${n[i]})) + ((n[i]=(${n[i]}<0)?3:${n[i]}%4)) + + # Print: + tput cup ${y[i]} ${x[i]} + echo -ne "\x1b[${BOLD}m" + [[ $NOCOLOR == 0 ]] && echo -ne "\x1b[3${c[i]}m" + echo -n "${sets[v[i]]:l[i]*4+n[i]:1}" + l[i]=${n[i]} + done + ((r>0 && t*p>=r)) && tput reset && tput civis && t=0 || ((t++)) +done + +cleanup diff --git a/.local/bin/pipesx b/.local/bin/pipesx new file mode 100755 index 0000000..2397b56 --- /dev/null +++ b/.local/bin/pipesx @@ -0,0 +1,207 @@ +#!/bin/bash +# Animated pipes.sh terminal screensaver at an angle. +# Copyright (c) 2013-2015 Yu-Jie Lin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# Website: https://github.com/pipeseroni/pipesX.sh + +VERSION=1.1.0 + +W=$(tput cols) H=$(tput lines) +# maximal random value + 1 +M=32768 + +SETS=('╱╲' '/\' '..' 'oo' '\/') +COLORS=(31 32 33 34 35 36 37) + +# default values +N=1 +T=() +I=0.05 +P=25 +R=$((W * H / 4)) + +HELP="Usage: $(basename $0) [OPTIONS] +Animated pipes.sh terminal screensaver at an angle. + +Options: + + -n [1-] number of pipes. (Default: $N) + -t [0-$((${#SETS[@]} - 1))] types of pipes, can be used more than once. (Default: $T) + -t c[2chs] custom type of pipes. + -i [float] piping interval or maze generation interval. (Default: $I) + -P [0-100] probability of a turning pipe or of \\ in maze generation. (Default: $P) + -r [LIMIT] reset after x characters, 0 if no limit. (Default: $R) + -R random starting point. + -C no color. + -X maze generation. + -h this help message. + -v print version number. +" + +while getopts "n:t:i:P:r:RCXhv" arg; do + case $arg in + n) + ((N = OPTARG > 0 ? OPTARG : N)) + ;; + t) + if [[ "$OPTARG" = c?? ]]; then + T+=(${#SETS[@]}) + SETS+=("${OPTARG:1}") + else + T+=($(((OPTARG >= 0 && OPTARG < ${#SETS[@]}) ? OPTARG : T))) + fi + ;; + i) + I=$OPTARG + ;; + P) + ((P = (OPTARG >= 0 && OPTARG <= 100) ? OPTARG : P)) + ;; + r) + ((R = OPTARG >= 0 ? OPTARG : R)) + ;; + R) + RNDSTART=1 + ;; + C) + NOCOLOR=1 + ;; + X) + MAZE=1 + ;; + h) + echo -e "$HELP" + exit 0 + ;; + v) + echo "$(basename -- "$0") $VERSION" + exit 0 + esac +done + +# set to default values if not by options +((${#T[@]})) || T=(0) + +do_exit() { + # clear up standard input + read -t 0.001 && cat /dev/null + + # terminal has no smcup and rmcup capabilities + ((FORCE_RESET)) && reset && exit 0 + + tput rmcup + tput cnorm + stty echo + ((NOCOLOR)) && echo -ne '\e[0m' + exit 0 + } +trap do_exit HUP TERM +trap 'break 2' INT + +# No echo stdin and hide the cursor +stty -echo +tput smcup || FORCE_RESET=1 +tput civis +tput clear + +# maze geneartion +while [[ $MAZE ]] && clear; do + [[ $NOCOLOR ]] || echo -ne "\e[1;${COLORS[${#COLORS[@]} * RANDOM / M]}m" + for ((i = 0; i < W * H; i++ )); do + echo -ne ${SETS[T]:100 * RANDOM / M < P:1} + done + read -t $I -n 1 && [[ $REPLY =~ q|Q ]] && do_exit +done + +# initialze values +for ((n = 0; n < N; n++)); do + ((X[n] = RNDSTART ? (W + 2) * RANDOM / M : W / 2)) + ((Y[n] = RNDSTART ? (H + 2) * RANDOM / M : H / 2)) + D[n]=$((4 * RANDOM / M)) + C[n]=${COLORS[${#COLORS[@]} * RANDOM / M]} + t[n]=${T[${#T[@]} * RANDOM / M]} +done + +clear +while REPLY=; read -t $I -n 1; [[ -z $REPLY ]] ; do + for ((n = 0; n < N; n++, CC = 0)); do + x=${X[n]} y=${Y[n]} + d=${D[n]} c=${C[n]} + + # calculate new direction `d` + # 1 0 + # \/ 4 directions 0 to 3 + # /\ + # 2 3 + # valid directions: d: dd', d' is the new direction + # d + # 0: / 00 \ 01 03 + # / / /\ + # 1: / 10 \ 11 12 + # \ \ /\ + # 2: \/ 21 / 22 / 23 + # / \ + # 3: \/ 30 \ 32 \ 33 + # / \ + ((d = (100 * RANDOM / M) < P ? ((d + 1) + 2 * (RANDOM % 2)) % 4 : d)) + ((e = (d + 1) % 4)) + + # calculate new position + # d' x' y' + # 0: x+1 y-1 + # 1: x-1 y-1 + # 2: x-1 y+1 + # 3: x+1 y+1 + ((xn = e < 2 ? x + 1 : x - 1)) + ((yn = d < 2 ? y - 1 : y + 1)) + + # adjust position and change color? + ((d < 2 && y == 0)) && ((yn--, CC=1)) + ((e > 1 && x == 0)) && ((xn--, CC=1)) + ((d > 1 && y == H)) && ((yn++, CC=1)) + ((e < 2 && x == W)) && ((xn++, CC=1)) + ((CC)) && c=${COLORS[${#COLORS[@]} * RANDOM / M]} + ((CC)) && t[n]=${T[${#T[@]} * RANDOM / M]} + + # warp pipe + ((xn = (xn + W + 1) % (W + 1))) + ((yn = (yn + H + 1) % (H + 1))) + + # calculate position in terminal + # d' xt yt + # 0: x' y'+1 + # 1: x'+1 y'+1 + # 2: x'+1 y' + # 3: x' y' + ((xt = e < 2 ? xn : xn + 1)) + ((yt = d < 2 ? yn + 1 : yn)) + + echo -ne "\e[${yt};${xt}H" + [[ $NOCOLOR ]] || echo -ne "\e[1;${c}m" + echo -n "${SETS[t[n]]:d%2:1}" + + X[n]=$xn Y[n]=$yn + D[n]=$d C[n]=$c + done + ((R)) && ((r += N, r >= R)) && r=0 && clear +done + +do_exit diff --git a/.local/bin/pod-dl b/.local/bin/pod-dl new file mode 100755 index 0000000..07e1d6b --- /dev/null +++ b/.local/bin/pod-dl @@ -0,0 +1,30 @@ +#!/bin/sh + +tmux kill-session -t Podcast 2 > /dev/null + +file=$(tail -n 1 $HOME/.local/share/newsboat/queue) +url=$(echo $file | sed 's/."\/home.*$//') +dir=$(echo $file | sed 's/^.*"\/home/\/home/; s/.$//') + +$TERMINAL -c dropdown -t Podcast -e $SCRIPTS/utilities/tmux-vlc "$url" + +# notify-send -i "$HOME/.fonts/svg/rss.svg" "Download initiated" +# wget -LO $dir $url && \ +# notify-send -i "$HOME/.fonts/svg/rss.svg" "Download Complete" && \ +# st -e $HOME/.scripts/tools/tm-vlc $dir + + +#!/bin/sh + +# tmux kill-session -t tm-vlc +# killall -q vlc + +# file=$(cat $HOME/.local/share/newsboat/queue | sed 2q | tail -n 1) +# url=$(echo $file | sed 's/."\/home.*$//') +# dir=$(echo $file | sed 's/^.*"\/home/\/home/; s/.$//') + +# notify-send -i "$HOME/.fonts/svg/rss.svg" "Download initiated" +# setsid wget -LO $dir $url & sleep 2s && st -e $HOME/.scripts/tools/tm-vlc "$dir" && \ +# notify-send -i "$HOME/.fonts/svg/rss.svg" "Download Complete" + +# echo "" > $HOME/.local/share/newsboat/queue diff --git a/.local/bin/podentr b/.local/bin/podentr new file mode 100755 index 0000000..a0997ba --- /dev/null +++ b/.local/bin/podentr @@ -0,0 +1,5 @@ +#!/bin/bash +# entr command to run `queueandnotify` when newsboat queue is changed + +# [ "$(pgrep -x $(basename $0) | wc -l)" -gt 2 ] && exit +echo /home/master/.local/share/newsboat/queue | entr -p $SCRIPTS/handling/pod-dl 2>/dev/null & diff --git a/.local/bin/powermenu b/.local/bin/powermenu new file mode 100755 index 0000000..994953e --- /dev/null +++ b/.local/bin/powermenu @@ -0,0 +1,11 @@ +#!/bin/sh + +choice=$(printf "Logout\\nShutdown\\nReboot\\nHibernate" | dmenu -i -p "Power Utility") + +case $choice in + *L*) $SCRIPTS/control/lockscreen ;; + *H*) systemctl suspend ;; + *R*) reboot ;; + *S*) shutdown -h now ;; + "") notify-send -i "$HOME/.fonts/svg/power-off.svg" -a Power "Operation suspended" +esac diff --git a/.local/bin/printermenu b/.local/bin/printermenu new file mode 100755 index 0000000..4487eae --- /dev/null +++ b/.local/bin/printermenu @@ -0,0 +1,3 @@ +#!/bin/sh + +lpstat -p -d | sed 's/^printer\ //; s/\ .*$//; s/no//; /^$/d' | dmenu -p "Select printer" diff --git a/.local/bin/qndl b/.local/bin/qndl new file mode 100755 index 0000000..df0bedf --- /dev/null +++ b/.local/bin/qndl @@ -0,0 +1,13 @@ +#!/bin/sh +# $1 is a url; $2 is a command +[ -z "$1" ] && exit +base="$(basename "$1")" +notify-send -i "$HOME/.fonts/svg/rss.svg" "Queuing $base..." +cmd="$2" +notify-send $cmd +[ -z "$cmd" ] && cmd="youtube-dl --add-metadata" +idnum="$(tsp $cmd "$1")" +realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")" +tsp -D "$idnum" mv "$base" "$HOME/Downloads/Podcasts/$realname" +tsp -D "$idnum" notify-send -i "$HOME/.fonts/svg/check-circle.svg" "$realname done." +tsp -D "$idnum" sleep 5s && st -e $HOME/.scripts/tools/tm-vlc "$HOME/Downloads/Podcasts/$realname" diff --git a/.local/bin/queueandnotify b/.local/bin/queueandnotify new file mode 100755 index 0000000..958b1be --- /dev/null +++ b/.local/bin/queueandnotify @@ -0,0 +1,15 @@ +#!/bin/sh +# Podboat sucks. This script replaces it. +# It reads the newsboat queue, queuing downloads with taskspooler. +# It also removes the junk from extentions. +queuefile="$HOME/.local/share/newsboat/queue" + +while read -r line; do + [ -z "$line" ] && continue + url="$(echo "$line" | awk '{print $1}')" + qndl "$url" "curl -LO" +done < "$queuefile" + +echo > "$queuefile" + + diff --git a/.local/bin/rain b/.local/bin/rain new file mode 100755 index 0000000..8a8d8f6 --- /dev/null +++ b/.local/bin/rain @@ -0,0 +1,100 @@ +#!/bin/bash +RAINS=("|" "│" "┃" "┆" "┇" "┊" "┋" "╽" "╿") +COLORS=("\e[37m" "\e[37;1m") +# More from 256 color mode +for i in {244..255}; do + COLORS=("${COLORS[@]}" "\e[38;5;${i}m") +done +NRAINS=${#RAINS[@]} +NCOLORS=${#COLORS[@]} +NUM_RAIN_METADATA=5 + + +sigwinch() { + TERM_WIDTH=$(tput cols) + TERM_HEIGHT=$(tput lines) + STEP_DURATION=0.025 + ((MAX_RAINS = TERM_WIDTH * TERM_HEIGHT / 4)) + ((MAX_RAIN_LENGTH = TERM_HEIGHT < 10 ? 1 : TERM_HEIGHT / 10)) + # In percentage + ((NEW_RAIN_ODD = TERM_HEIGHT > 50 ? 100 : TERM_HEIGHT * 2)) + ((NEW_RAIN_ODD = NEW_RAIN_ODD * 75 / 100)) + ((FALLING_ODD = TERM_HEIGHT > 25 ? 100 : TERM_HEIGHT * 4)) + ((FALLING_ODD = FALLING_ODD * 90 / 100)) + } + +do_exit() { + echo -ne "\e[${TERM_HEIGHT};1H\e[0K" + + # Show cursor and echo stdin + echo -ne "\e[?25h" + stty echo + exit 0 + } + +do_render() { + # Clean screen first + for ((idx = 0; idx < num_rains * NUM_RAIN_METADATA; idx += NUM_RAIN_METADATA)); do + X=${rains[idx]} + Y=${rains[idx + 1]} + LENGTH=${rains[idx + 4]} + for ((y = Y; y < Y + LENGTH; y++)); do + (( y < 1 || y > TERM_HEIGHT )) && continue + echo -ne "\e[${y};${X}H " + done + done + + for ((idx = 0; idx < num_rains * NUM_RAIN_METADATA; idx += NUM_RAIN_METADATA)); do + if ((100 * RANDOM / 32768 < FALLING_ODD)); then + # Falling + if ((++rains[idx + 1] > TERM_HEIGHT)); then + # Out of screen, bye sweet <3 + rains=("${rains[@]:0:idx}" + "${rains[@]:idx+NUM_RAIN_METADATA:num_rains*NUM_RAIN_METADATA}") + ((num_rains--)) + continue + fi + fi + X=${rains[idx]} + Y=${rains[idx + 1]} + RAIN=${rains[idx + 2]} + COLOR=${rains[idx + 3]} + LENGTH=${rains[idx + 4]} + for ((y = Y; y < Y + LENGTH; y++)); do + (( y < 1 || y > TERM_HEIGHT )) && continue + echo -ne "\e[${y};${X}H${COLOR}${RAIN}" + done + done + } + +trap do_exit TERM INT +trap sigwinch WINCH +# No echo stdin and hide the cursor +stty -echo +echo -ne "\e[?25l" + +echo -ne "\e[2J" +rains=() +sigwinch +while :; do + read -n 1 -t $STEP_DURATION ch + case "$ch" in + q|Q) + do_exit + ;; + esac + + if ((num_rains < MAX_RAINS)) && ((100 * RANDOM / 32768 < NEW_RAIN_ODD)); then + # Need new |, 1-based + RAIN="${RAINS[NRAINS * RANDOM / 32768]}" + COLOR="${COLORS[NCOLORS * RANDOM / 32768]}" + LENGTH=$((MAX_RAIN_LENGTH * RANDOM / 32768 + 1)) + X=$((TERM_WIDTH * RANDOM / 32768 + 1)) + Y=$((1 - LENGTH)) + rains=("${rains[@]}" "$X" "$Y" "$RAIN" "$COLOR" "$LENGTH") + ((num_rains++)) + fi + + # Let rain fall! + do_render +done \ No newline at end of file diff --git a/.local/bin/recordmenu b/.local/bin/recordmenu new file mode 100755 index 0000000..32b0a34 --- /dev/null +++ b/.local/bin/recordmenu @@ -0,0 +1,105 @@ +#!/bin/sh + +# Usage: +# `record`: Ask for recording type via dmenu +# `record screencast`: Record both audio and screen +# `record video`: Record only screen +# `record audio`: Record only audio +# `record kill`: Kill existing recording +# +# If there is already a running instance, user will be prompted to end it. + +updateicon() { \ + echo "$1" > /tmp/recordingicon + pkill -RTMIN+9 i3blocks + } + +killrecording() { + recpid="$(cat /tmp/recordingpid)" + # kill with SIGTERM, allowing finishing touches. + kill -15 "$recpid" + rm -f /tmp/recordingpid + updateicon "" + pkill -RTMIN+9 i3blocks + # even after SIGTERM, ffmpeg may still run, so SIGKILL it. + sleep 3 + kill -9 "$recpid" + exit + } + +screencast() { \ + ffmpeg -y \ + -f x11grab \ + -framerate 60 \ + -s $(xdpyinfo | grep dimensions | awk '{print $2;}') \ + -i :0.0 \ + -f alsa -i default \ + -r 30 \ + -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \ + "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > /tmp/recordingpid + updateicon "" + } + +video() { ffmpeg \ + -f x11grab \ + -s $(xdpyinfo | grep dimensions | awk '{print $2;}') \ + -i :0.0 \ + -c:v libx264 -qp 0 -r 30 \ + "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > /tmp/recordingpid + updateicon "" + } + +webcamhidef() { ffmpeg \ + -f v4l2 \ + -i /dev/video0 \ + -video_size 1920x1080 \ + "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > /tmp/recordingpid + updateicon "" + } + +webcam() { ffmpeg \ + -f v4l2 \ + -i /dev/video0 \ + -video_size 640x480 \ + "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > /tmp/recordingpid + updateicon "" + } + + +audio() { \ + ffmpeg \ + -f alsa -i default \ + -c:a flac \ + "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & + echo $! > /tmp/recordingpid + updateicon "" + } + +askrecording() { \ + choice=$(printf "screencast\\nvideo\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style") + case "$choice" in + screencast) screencast;; + audio) audio;; + video) video;; + webcam) webcam;; + "webcam (hi-def)") webcamhidef;; + esac + } + +asktoend() { \ + response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") && + [ "$response" = "Yes" ] && killrecording + } + + +case "$1" in + screencast) screencast;; + audio) audio;; + video) video;; + kill) killrecording;; + *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;; +esac diff --git a/.local/bin/rssadd b/.local/bin/rssadd new file mode 100755 index 0000000..8822fc5 --- /dev/null +++ b/.local/bin/rssadd @@ -0,0 +1,9 @@ +#!/bin/sh +! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null && + notify-send "That doesn't look like a full URL." && exit +RSSFILE="$HOME/.config/newsboat/urls" +if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then + notify-send "You already have this RSS feed." +else + echo "$1" >> "$RSSFILE" && notify-send "RSS feed added." +fi diff --git a/.local/bin/screenstatus b/.local/bin/screenstatus new file mode 100755 index 0000000..009c01f --- /dev/null +++ b/.local/bin/screenstatus @@ -0,0 +1,4 @@ +#!/bin/sh + +notify-send.sh --replace-file /tmp/vol-notif -a "Screen Brightness" "$(xbacklight -get)%" + diff --git a/.local/bin/setbg b/.local/bin/setbg new file mode 100755 index 0000000..03f2bd0 --- /dev/null +++ b/.local/bin/setbg @@ -0,0 +1,20 @@ +#!/bin/sh + +# This script does the following: +# Run by itself, set the wallpaper (at X start). +# If given a file, set that as the new wallpaper. +# If given a directory, choose random file in it. +# If wal is installed, also generate a colorscheme. + +# Location of link to wallpaper link. +bgloc="${XDG_CACHE_HOME:-$HOME/.cache/}/wall.png" + +[ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." + +[ -d "$1" ] && ln -sf "$(find "$(readlink -f "$1")" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." + +# # If pywal is installed, use it. +# wal -s -i "$(readlink -f "$bgloc")" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 + +xwallpaper --zoom "$bgloc" & + diff --git a/.local/bin/shortcutgen b/.local/bin/shortcutgen new file mode 100755 index 0000000..aa4a452 --- /dev/null +++ b/.local/bin/shortcutgen @@ -0,0 +1,54 @@ +#!/bin/sh + +# Removing unecessary comments and documentation +raw=$(cat $HOME/.config/shortcutrc | tail -n +19 "$HOME/.config/shortcutrc" | sed "s/^|\s*//g; + s/\(.*\)|\(.*\)|\(.*\)|/\1|\2|\3/g; + s/\s*$//g; + /^$/d") +# #---NERDTREE---# # +echo "$raw" | sed "s/\(.*\)\s*|.*|\s\(.*\)/\1\2/g; + s/ \{1,\}/ /g; + s/.HOME/~/g; + s/-*+-*+-*|//g" > $HOME/.NERDTreeBookmarks + +# #---ZSH---# # +# be sure to source $HOME/.cache/zsh-shortcuts in your .zshrc +echo "$raw" | sed 's/^.*|\s\([A-Za-z0-9]*\)\s*|\s\(.*\)$/alias\ g\1="cd\ \2"/g; /^-*+-*+-*|$/d' > $HOME/.cache/zsh-shortcuts + +# #---RANGER---# # +# Commands implemented: +# g -> go +# m -> move to... +# t -> new tab +# Y -> copy to... +# awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts" +manual=$(sed -n '/Automated Shortcut Generation/q;p' $HOME/.config/ranger/shortcuts.conf) +printf '\n\n# #---Automated Shortcut Generation---#' >> $HOME/.config/ranger/shortcuts.conf +echo "$raw" | sed 's/^.*|\s\(.*\)\s|\s\(.*\)$/map\ g\1\ cd\ \2\nmap\ t\1\ tab_new\ \2\nmap\ m\1\ shell\ mv\ -v\ %s\ \2\nmap\ Y\1\ shell\ cp\ -rv\ %s\ \2\n/g; + s/.HOME/~/g; + s/^-*+-*+-*|$//g' >> $HOME/.config/ranger/shortcuts.conf + +# #---ENVIRONMENTAL VARIABLES---# # +echo "$raw" | sed 's/[A-z,a-z,0-9]*\s*|\s*/g/; + s/\s*|\s*/=/; s/$/"/; + s/-*+-*+.*$// + s/^[A-z]*=/\U&/g + s/"$//g' > ~/.cache/shell-vars + +# #---Vifm---# # +vifm=$(echo "$raw" | sed " + s/^[A-Z,a-z,0-9]*\s*|//; + s/|/:cd/; + s/\$HOME/~/; + s/^-.*//" +) +vifmgo=$( echo "$vifm" | sed " + s/\s*/nnoremap\ g/; + s/$//" +) +echo "$vifmgo" > ~/.cache/vifm-shortcuts + +# #---Testing---# # +# echo "$raw" | sed "s/[A-z,a-z,0-9]*\s*|//" + +# echo "$raw" diff --git a/.local/bin/slendy b/.local/bin/slendy new file mode 100755 index 0000000..766e06c --- /dev/null +++ b/.local/bin/slendy @@ -0,0 +1,35 @@ +#!/bin/sh + +initializeANSI() +{ + esc="" + + blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" + yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" + cyanf="${esc}[36m"; whitef="${esc}[37m" + + blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" + yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" + cyanb="${esc}[46m"; whiteb="${esc}[47m" + + boldon="${esc}[1m"; boldoff="${esc}[22m" + italicson="${esc}[3m"; italicsoff="${esc}[23m" + ulon="${esc}[4m"; uloff="${esc}[24m" + invon="${esc}[7m"; invoff="${esc}[27m" + + reset="${esc}[0m" +} + +initializeANSI + +cat << EOF + + ${reset}${blackf}| | | | |${reset} + ${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █${reset} + ${redf}███████${reset} ${blackf}|${reset} ${greenf}███████${reset} ${blackf}|${reset} ${yellowf}███████${reset} ${blackf}|${reset} ${bluef}███████${reset} ${blackf}|${reset} ${purplef}███████${reset} ${blackf}|${reset} ${cyanf}███████${reset} + ${redf}███${boldon}${redb}██${reset}${redf}█${boldon}${redb}██${reset}${redf}███${reset} ${blackf}|${reset} ${greenf}███${boldon}${greenb}██${reset}${greenf}█${boldon}${greenb}██${reset}${greenf}███${reset} ${blackf}|${reset} ${yellowf}███${boldon}${yellowb}██${reset}${yellowf}█${boldon}${yellowb}██${reset}${yellowf}███${reset} ${blackf}|${reset} ${bluef}███${boldon}${blueb}██${reset}${bluef}█${boldon}${blueb}██${reset}${bluef}███${reset} ${blackf}|${reset} ${purplef}███${boldon}${purpleb}██${reset}${purplef}█${boldon}${purpleb}██${reset}${purplef}███${reset} ${blackf}|${reset} ${cyanf}███${boldon}${cyanb}██${reset}${cyanf}█${boldon}${cyanb}██${reset}${cyanf}███${reset} + ${redf}████${boldon}${redb}█${reset}${redf}████${reset} ${blackf}|${reset} ${greenf}████${boldon}${greenb}█${reset}${greenf}████${reset} ${blackf}|${reset} ${yellowf}████${boldon}${yellowb}█${reset}${yellowf}████${reset} ${blackf}|${reset} ${bluef}████${boldon}${blueb}█${reset}${bluef}████${reset} ${blackf}|${reset} ${purplef}████${boldon}${purpleb}█${reset}${purplef}████${reset} ${blackf}|${reset} ${cyanf}████${boldon}${cyanb}█${reset}${cyanf}████${reset} + ${redf}█ █ ${boldon}█${reset} ${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █ ${boldon}█${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █ ${boldon}█${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █ ${boldon}█${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █ ${boldon}█${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █ ${boldon}█${reset} ${cyanf}█ █${reset} + ${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █${reset} + ${blackf}| | | | |${reset} +EOF \ No newline at end of file diff --git a/.local/bin/surfmenu b/.local/bin/surfmenu new file mode 100755 index 0000000..0f046e0 --- /dev/null +++ b/.local/bin/surfmenu @@ -0,0 +1,4 @@ +#!/bin/sh + +url=$(cat ~/.surf/bookmarks | dmenu -i -p "Go: ") +surf "$url" diff --git a/.local/bin/tdout b/.local/bin/tdout new file mode 100755 index 0000000..2d23464 --- /dev/null +++ b/.local/bin/tdout @@ -0,0 +1,9 @@ +#!/bin/sh +# opout: "open output": A general handler for opening a file's intended output. +# I find this useful especially running from vim. + +basename="$(echo "$1" | sed 's/\.[^\/.]*$//')" + +case "$1" in + *.tex|*.rnw|*.gd|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename"-tdtable.pdf >/dev/null 2>&1 & ;; +esac diff --git a/.local/bin/test.sh b/.local/bin/test.sh new file mode 100755 index 0000000..a1d8a9e --- /dev/null +++ b/.local/bin/test.sh @@ -0,0 +1,9 @@ +#!/usr/bin + +for i in $(ls ~/manjaro-dotfiles/.scripts/) +do + for j in $(ls ~/manjaro-dotfiles/.scripts/$i) + do + cp ~/manjaro-dotfiles/.scripts/$i/$j ~/.local/bin/ + done +done diff --git a/.local/bin/texclear b/.local/bin/texclear new file mode 100755 index 0000000..88667e3 --- /dev/null +++ b/.local/bin/texclear @@ -0,0 +1,32 @@ +#!/bin/sh + +# Clears the build files of a LaTeX/XeLaTeX build. +# I have vim run this file whenever I exit a .tex file. + +case "$1" in + *.tex) + file=$(readlink -f "$1") + dir=$(dirname "$file") + base="${file%.*}" + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete + ;; + *.rnw) + file=$(readlink -f "$1") + dir=$(dirname "$file") + base="${file%.*}" + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl|tex|Rout)" -delete + rm "$dir"/Rplots.pdf + rm "$dir"/.Rhistory + # rm "$dir"/.Rhistory + ;; + *.rmd) + file=$(readlink -f "$1") + dir=$(dirname "$file") + base="${file%.*}" + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl|tex|Rout)" -delete + rm "$dir"/Rplots.pdf + rm "$dir"/.Rhistory + ;; + *) printf "Give .tex, .rnw, or .rmd file as argument.\\n" ;; +esac + diff --git a/.local/bin/texinit b/.local/bin/texinit new file mode 100755 index 0000000..5568c99 --- /dev/null +++ b/.local/bin/texinit @@ -0,0 +1,6 @@ +#!/bin/sh + +cp $HOME/Dropbox/A/Scholar/All/Templates/Text/LaTeX/001personal/cegep-lanaudiere/article/* ./ +ln $BIB/citations.bib ./citations.bib +mkdir archives + diff --git a/.local/bin/tmux-mpsyt b/.local/bin/tmux-mpsyt new file mode 100755 index 0000000..b929d52 --- /dev/null +++ b/.local/bin/tmux-mpsyt @@ -0,0 +1,16 @@ +#!/bin/sh +# This script ensures that i3 will spawn a youtube tui. +session="mps-YouTube" + +# Check if the session exists, discarding output +# We can check $? for the exit status (zero for success, non-zero for failure) +tmux has-session -t $session 2>/dev/null + +if [ $? != 0 ]; then + # Set up your session + tmux new-session -d -s "$session" mpsyt +fi + +# Attach to created session +tmux attach-session -t $session + diff --git a/.local/bin/tmux-r b/.local/bin/tmux-r new file mode 100755 index 0000000..14dd08a --- /dev/null +++ b/.local/bin/tmux-r @@ -0,0 +1,18 @@ +#!/bin/sh +# This script ensures that i3 will spawn a youtube tui. +session="R" + +# Check if the session exists, discarding output +# We can check $? for the exit status (zero for success, non-zero for failure) +tmux has-session -t $session 2>/dev/null + +if [ $? != 0 ]; then + # Set up your session + tmux new-session -d -s "$session" R -q --no-save + # R -q --no-save + # ([ -e /usr/bin/R ] && R -q --no-save) || python -q +fi + +# Attach to created session +tmux attach-session -t $session + diff --git a/.local/bin/tmux-shell b/.local/bin/tmux-shell new file mode 100755 index 0000000..9c95cf7 --- /dev/null +++ b/.local/bin/tmux-shell @@ -0,0 +1,18 @@ +#!/bin/sh +# This script ensures that i3 will spawn a youtube tui. +session="Shell" + +# Check if the session exists, discarding output +# We can check $? for the exit status (zero for success, non-zero for failure) +tmux has-session -t $session 2>/dev/null + +if [ $? != 0 ]; then + # Set up your session + tmux new-session -d -s "$session" zsh + # R -q --no-save + # ([ -e /usr/bin/R ] && R -q --no-save) || python -q +fi + +# Attach to created session +tmux attach-session -t $session + diff --git a/.local/bin/tmux-vlc b/.local/bin/tmux-vlc new file mode 100755 index 0000000..dc26c49 --- /dev/null +++ b/.local/bin/tmux-vlc @@ -0,0 +1,19 @@ +#!/bin/sh +# This script ensures that i3 will spawn a youtube tui. +session="Podcast" +url=$1 + +# Check if the session exists, discarding output +# We can check $? for the exit status (zero for success, non-zero for failure) +tmux has-session -t $session 2>/dev/null + +if [ $? != 0 ]; then + # Set up your session + tmux new-session -d -s "$session" vlc -I ncurses "$url" + # R -q --no-save + # ([ -e /usr/bin/R ] && R -q --no-save) || python -q +fi + +# Attach to created session +tmux attach-session -t $session + diff --git a/.local/bin/todotable b/.local/bin/todotable new file mode 100755 index 0000000..6609a1f --- /dev/null +++ b/.local/bin/todotable @@ -0,0 +1,23 @@ +#!/bin/sh + +file=$(readlink -f "$1") +dir=$(dirname "$file") +base="${file%.*}" + +contents="$1" +shift +for i in "$@"; do + output=$output"\n"$(cat "$contents" | grep -n "$i" | sed 's/\([0-9]*\):.*'"$i"'.\(.*\)$/-\ \*\*'"$i"':\*\*\ \2\ (line \1)/g' + ) +done + + +if [ "$#" -eq $(printf $output | wc -l ) ]; +then + rm "$base"-tdtable.pdf + exit 0 +else + echo -e '---\ntitle: Checklist:\n.PP'"$output" | groffdown | refer -PS -e "-p$REFERBIB" | groff -me -ms -kejpt -T pdf > "$base"-tdtable.pdf +fi +# Uncomment for debugging: +# echo -e '---\ntitle: TODOs\n.PP'"$output" > "$base"-tdtable.gd diff --git a/.local/bin/trackpadtoggle b/.local/bin/trackpadtoggle new file mode 100755 index 0000000..4bf01ae --- /dev/null +++ b/.local/bin/trackpadtoggle @@ -0,0 +1,15 @@ +#!/bin/sh + +# Give this the 1 argument to activate the Trackpad. +# Give this 0 to disable it. + +input="$1" + +xinput --set-prop 12 "Device Enabled" $input + +case "$input" in + 0) notify-send -i "$HOME/.fonts/svg/mouse-pointer.svg" -a Trackpad "Trackpad successfully disabled" ;; + 1) notify-send -i "$HOME/.fonts/svg/mouse-pointer.svg" -a Trackpad "Trackpad successfully enabled" ;; + *) notify-send -i "$HOME/.fonts/svg/mouse-pointer.svg" -a Trackpad "Error" ;; +esac + diff --git a/.local/bin/transadd b/.local/bin/transadd new file mode 100755 index 0000000..f7e95d6 --- /dev/null +++ b/.local/bin/transadd @@ -0,0 +1,9 @@ +#!/bin/sh + +# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running. + +# transmission-daemon sometimes fails to take remote requests in its first moments. + +pgrep -x transmission-da || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks) + +transmission-remote -a "$@" && notify-send " Torrent added." diff --git a/.local/bin/umountmenu b/.local/bin/umountmenu new file mode 100755 index 0000000..39940a3 --- /dev/null +++ b/.local/bin/umountmenu @@ -0,0 +1,42 @@ +#!/bin/sh +# A dmenu prompt to unmount drives. +# Provides you with mounted partitions, select one to unmount. +# Drives mounted at /, /boot, /games and /home will not be options to unmount. + +unmountusb() { + [ -z "$drives" ] && exit + chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}') + [ -z "$chosen" ] && exit + sudo -A umount "$chosen" && notify-send -i "$HOME/.fonts/svg/usb.svg" -a "USB Mounting" "$chosen unmounted." + } + +unmountandroid() { \ + chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?") + [ -z "$chosen" ] && exit + sudo -A umount -l "$chosen" && notify-send -i "$HOME/.fonts/svg/android.svg" -a "Android unmounting + $chosen unmounted." + } + +asktype() { \ + case "$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" in + USB) unmountusb ;; + Android) unmountandroid ;; + esac + } + +drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/games|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}') + +if ! grep simple-mtpfs /etc/mtab; then + [ -z "$drives" ] && notify-send -i "~/.fonts/svg/usb.svg" -a "USB Mounting" "No drives to unmount." && exit + echo "Unmountable USB drive detected." + unmountusb +else + if [ -z "$drives" ] + then + echo "Unmountable Android device detected." + unmountandroid + else + echo "Unmountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.local/bin/unix b/.local/bin/unix new file mode 100755 index 0000000..14d7ef0 --- /dev/null +++ b/.local/bin/unix @@ -0,0 +1,25 @@ +#!/bin/sh +#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes +#converted to shell by #nixers @ irc.unix.chat + +cat << 'eof' + ,_ ,_==▄▂ + , ▂▃▄▄▅▅▅▂▅¾. / / + ▄▆<´ "»▓▓▓%\ / / / / + ,▅7" ´>▓▓▓% / / > / >/% + ▐¶▓ ,»▓▓¾´ /> %/%// / / + ▓▃▅▅▅▃,,▄▅▅▅Æ\// ///>// />/ / + V║«¼.;→ ║<«.,`=// />//%/% / / + //╠<´ -²,)(▓~"-╝/¾/ %/>/ /> + / / / ▐% -./▄▃▄▅▐, /7//;//% / / + / ////`▌▐ %zWv xX▓▇▌//&;% / / + / / / %//%/¾½´▌▃▄▄▄▄▃▃▐¶\/& / + </ /)VY>7; \_ UNIX IS VERY SIMPLE IT JUST NEEDS A + / /</ //<///<_/%\▓ V%W%£)XY _/%‾\_, GENIUS TO UNDERSTAND ITS SIMPLICITY + / / //%/_,=--^/%/%%\¾%¶%%} /%%%%%%;\, + %/< /_/ %%%%%;X%%\%%;, _/%%%;, \ + / / %%%%%%;, \%%l%%;// _/%;, dmr + / %%%;, <;\-=-/ / + ;, l +eof \ No newline at end of file diff --git a/.local/bin/vifmrun b/.local/bin/vifmrun new file mode 100755 index 0000000..69f2d22 --- /dev/null +++ b/.local/bin/vifmrun @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}" + +function cleanup() { + rm "$FIFO_UEBERZUG" 2>/dev/null + pkill -P $$ 2>/dev/null +} + +rm "$FIFO_UEBERZUG" 2>/dev/null +mkfifo "$FIFO_UEBERZUG" +trap cleanup EXIT +tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash & + +vifm "$@" +cleanup diff --git a/.local/bin/volumectl b/.local/bin/volumectl new file mode 100755 index 0000000..d8766b7 --- /dev/null +++ b/.local/bin/volumectl @@ -0,0 +1,23 @@ +#!/bin/bash + +# Usage: + +# The first argument is the percentage by which you should +# change the volume + +# The second argument should be `+` or `-` +# to choose wether to increment or decrement audio. +# If no second argument is given, the audio will be SET +# to a set percentage fixed by the first argument. +case "$1" in + mute) amixer set Master toggle ;; + *) pcnt="$1" + sign="$2" + amixer set Master $pcnt%$sign ;; +esac + +mute="" +vol=$(awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)) +amixer sget Master | grep off && mute="(muted)" +notify-send.sh -t 1000 --replace-file /tmp/vol-notif -a Volume "$vol $mute" + diff --git a/.local/bin/vpnmenu b/.local/bin/vpnmenu new file mode 100755 index 0000000..d679c49 --- /dev/null +++ b/.local/bin/vpnmenu @@ -0,0 +1,14 @@ +#!/bin/sh + +current=$(expressvpn status | sed "s/.......................//; 1q") + +location=$(expressvpn list recomend | sed "1,4d; s/^.*\t//" | head | dmenu -l 10) + +if [ ! -n "$location" ] +then + notify-send -i "$HOME/.fonts/svg/shield.svg" -a "VPN Module" "Operation aborted" +else + expressvpn disconnect; expressvpn connect "$location" +fi + +# expressvpn disconnect; expressvpn connect "$location" diff --git a/.local/bin/vpnstatus b/.local/bin/vpnstatus new file mode 100755 index 0000000..908aa76 --- /dev/null +++ b/.local/bin/vpnstatus @@ -0,0 +1,25 @@ +#!/bin/bash +# Outputs if Express VPN is connected or not + +vpnstatus=$(expressvpn status | head -n 1) + +case "$vpnstatus" in + *"Not"*) icon="" + ;; + *"Connected"*) icon="" + ;; + *"Connecting"*) icon=" " + ;; + *) icon="" +esac + +echo " $icon " + + +# \033]01;31\] # pink +# \033]00m\] # white +# \033]01;36\] # bold green +# \033]02;36\] # green +# \033]01;34\] # blue +# \033]01;33\] # bold yellow +# s/onnected\sto\s//; diff --git a/.local/bin/websearch b/.local/bin/websearch new file mode 100755 index 0000000..2de2c75 --- /dev/null +++ b/.local/bin/websearch @@ -0,0 +1,31 @@ +#!/bin/sh +# Gives a dmenu prompt to search Google. +# Without input, will open Google.com. +# URLs will be directly handed to the browser. +# Anything else, it search it. + +query=$(printf " " | dmenu -i -p " Search Google") + +echo "$query" | head -c 1 + +if [ $(echo "$query" | head -c 1) == "\!" ]; then + $BROWSER "https://duckduckgo.com/?q=$query&t=ffab&atb=v1-1" +else + $BROWSER "https://google.com/?q=$query&t=ffab&atb=v1-1" +fi + + +# # pgrep -x dmenu && exit +# # pgrep -x dmenu + +# choice=$(echo "" | dmenu -i -p " Search DuckDuckGo") || exit 1 + +# if [ "$choice" = "" ]; then +# firefox "https://duckduckgo.com" +# else +# if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then +# firefox "$choice" +# else +# firefox "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" +# fi +# fi diff --git a/.local/bin/wifi b/.local/bin/wifi new file mode 100755 index 0000000..102a6a4 --- /dev/null +++ b/.local/bin/wifi @@ -0,0 +1,10 @@ +#!/bin/sh + +case "$(cat /sys/class/net/wlp0s20f3/operstate)" in + up) echo "  " ;; + down) echo "  " ;; +esac + +#  +#  +#  diff --git a/.local/bin/yadms b/.local/bin/yadms new file mode 100755 index 0000000..56e8fce --- /dev/null +++ b/.local/bin/yadms @@ -0,0 +1,15 @@ +#!/bin/bash + +dotfiles=$(yadm status | sed '1,3d; + 5,$d; + s/.$//g') + +if [[ ${dotfiles:0:1} == "n" ]]; then + warn="" +else + warn="  " +fi + + + +echo "  $warn" -- cgit v1.2.3