--- /dev/null
+#!/bin/bash
+
+# Vertical monitor is connected as DP-0, Horizontal monitor is connected as HDMI-0
+# Horizontal monitor is disconnected for the PS4. This script monitors the output
+# of xrandr and runs the multimonitor script if needed
+
+MMSCRIPT=~/.screenlayout/multimonitor.sh
+HDMI=$(xrandr | grep -c HDMI-0)
+
+if [[ HDMI -eq 1 ]]; then
+ $MMSCRIPT
+fi
--- /dev/null
+#!/bin/sh
+
+# Requires ffmpeg (audio splitting) and my `tag` wrapper script.
+
+[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
+
+echo "Enter the album/book title:"; read -r booktitle
+
+echo "Enter the artist/author:"; read -r author
+
+echo "Enter the publication year:"; read -r year
+
+inputaudio="$1"
+
+# Get a safe file name from the book.
+escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
+
+! mkdir -p "$escbook" && echo "Do you have write access in this directory?" && exit 1
+
+# As long as the extension is in the tag script, it'll work.
+ext="opus"
+#ext="${1#*.}"
+
+# Get the total number of tracks from the number of lines.
+total="$(wc -l < "$2")"
+
+while read -r x;
+do
+ end="$(echo "$x" | cut -d' ' -f1)"
+ [ -n "$start" ] &&
+ echo "From $start to $end; $track $title"
+ file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
+ [ -n "$start" ] && echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn "$file" &&
+ echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
+ title="$(echo "$x" | cut -d' ' -f 2-)"
+ esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
+ track="$((track+1))"
+ start="$end"
+done < "$2"
+# The last track must be done outside the loop.
+echo "From $start to the end: $title"
+file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
+echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn "$file" &&
+ echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
--- /dev/null
+#!/bin/bash
+
+mupdf ~/documents/books/BraveNewWorld.pdf
--- /dev/null
+#!/bin/bash
+function connect()
+{
+ echo -e "connect E8:AB:FA:25:43:EE\n" | bluetoothctl
+}
+
+function disconnect()
+{
+ echo -e "disconnect\n" | bluetoothctl
+}
+
+function usage()
+{
+ echo "Usage: $0 {c|d}"
+ echo "_C_onnect/_D_isconnect from bluetooth headphones"
+}
+
+if [[ $# -ne 1 ]]; then
+ usage
+ exit 1
+fi
+
+if [[ $1 == "c" ]]; then
+ connect
+ exit 0
+elif [[ $1 == "d" ]]; then
+ disconnect
+ exit 0
+else
+ usage
+ exit 0
+fi
--- /dev/null
+#!/bin/bash
+#pkill -f /dev/video || mpv --geometry=-0-0 --autofit=30% --no-cache-pause /dev/video0
+#pkill -f camout.mkv || ffmpeg -f mjpg -video_size 640x480 -i /dev/video0 camout.mkv ; mpv --geometry=-0-0 --autofit=30% camout.mkv
+pkill -f vlc || cvlc v4l2:///dev/video0 --live-caching=10
--- /dev/null
+#!/usr/bin/env bash
+#
+# colorbars - smpte color bars in bash
+#
+
+echo
+
+for y in {0..13};
+ do
+ echo -n " "
+ for color in 7 3 6 2 5 1 4;
+ do tput setab $color
+ printf " ";
+ done
+ tput sgr0
+ echo;
+done
+
+for y in {0..1};
+ do
+ echo -n " "
+ for color in 4 0 5 0 6 0 7;
+ do tput setab $color
+ printf " ";
+ done
+ tput sgr0
+ echo;
+done
+
+for y in {0..4};
+ do
+ echo -n " "
+ 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 " ";
+ done
+ tput sgr0
+ echo;
+done
+
+echo
--- /dev/null
+#!/bin/bash
+
+ps axch -o cmd:15,%cpu --sort=-%cpu | sed 11q
--- /dev/null
+#!/bin/bash
+
+sensors | awk '/^temp1:/ {print $2}'
--- /dev/null
+#!/bin/bash
+
+rootDir='/home/mokou/git/cecse'
+proj=$(ls $rootDir | dmenu -l 10 \
+ -fn 'xos4 Terminus-15' -nb '#1c1c1c' -sb '#b35050')
+
+[ -z $proj ] && exit
+
+# creating the project if it doesn't exist
+projExists=$(find $rootDir -maxdepth 1 -type d -name $proj)
+if [ -z $projExists ]; then
+ cd $rootDir
+ notify-send 'cecse' "creating $proj module, please wait..."
+ ./scripts/new_module $proj
+ notify-send 'cecse' "adding owens.tech remotes..."
+ ssh git@owens.tech "mkdir cecse/$proj.git cecse/test-$proj.git;\
+ cd $proj.git; git init --bare; cd ../$test-proj.git;\
+ git init --bare"
+ cd $proj
+ git remote set-url --add --push origin git@github.com:cecse/$proj.git
+ git remote set-url --add --push origin git@owens.tech:cecse/$proj.git
+ cd ../test-$proj
+ git remote set-url --add --push origin git@github.com:cecse/$proj.git
+ git remote set-url --add --push origin git@owens.tech:cecse/$proj.git
+ cd ..
+fi
+
+(tmux has-session -t $proj)
+sessionExists="$?"
+
+if [ $sessionExists -eq 1 ]; then
+ cd $rootDir/$proj
+ tmux new-session -d -s $proj
+
+ # rename default window
+ tmux rename-window -t $proj.0 'src'
+ tmux new-window -t $proj -n 'tests'
+ tmux new-window -t $proj -n 'build'
+ tmux send-keys -t $proj:src 'cd src;ls' C-m
+ tmux send-keys -t $proj:tests "cd test-$proj;ls" C-m
+ tmux send-keys -t $proj:build 'ls' C-m
+fi
+
+client=$(tmux list-clients | grep -v '0 ' | cut -d: -f1)
+tmux switch-client -c $client -t $proj
--- /dev/null
+#!/bin/bash
+
+site=$(cat ~/.surf/bookmarks | dmenu -l 10 \
+ -fn 'xos4 Terminus-15' -nb '#1c1c1c' -sb '#b35050')
+[ -z "$site" ] || surf -b $site
--- /dev/null
+#!/bin/sh
+
+# statusbar loop
+while true; do
+ xsetroot -name "$(date +"%F %T")"
+ sleep 1s
+done
--- /dev/null
+setxkbmap gb && setxkbmap -option caps:swapescape
--- /dev/null
+#!/bin/sh
+
+# Feed script a url or file location.
+# If an image, it will view in feh,
+# 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 mpv -quiet "$1" >/dev/null 2>&1 & ;;
+ *png|*jpg|*jpe|*jpeg|*gif)
+ curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && feh -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
+ *mp3|*flac|*opus|*mp3?source*)
+ setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
+ *)
+ if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
+ else setsid $BROWSER "$1" >/dev/null 2>&1 & fi ;;
+esac
--- /dev/null
+#!/bin/bash
+
+ps axch -o cmd:15,%mem --sort=-%mem | sed 11q
--- /dev/null
+#!/bin/sh
+#
+# z3bra - (c) wtfpl 2014
+# Fetch infos on your computer, and print them to stdout every second.
+
+clock() {
+ date '+%Y-%m-%d %H:%M:%S'
+}
+
+battery() {
+ BATC=/sys/class/power_supply/BAT1/capacity
+ BATS=/sys/class/power_supply/BAT1/status
+
+ test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
+
+ sed -n p $BATC
+}
+
+volume() {
+ amixer get Master | sed -n 'N;s/^.*\[\([0-9]\+%\).*$/\1/p'
+}
+
+cpuload() {
+ LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
+ bc <<< $LINE
+}
+
+memused() {
+ read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo |awk '{print $2}'`
+ bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
+}
+
+network() {
+ read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'`
+ if iwconfig $int1 >/dev/null 2>&1; then
+ wifi=$int1
+ eth0=$int2
+ else
+ wifi=$int2
+ eth0=$int1
+ fi
+ ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 ||int=$wifi
+
+ #int=eth0
+
+ ping -c 1 8.8.8.8 >/dev/null 2>&1 &&
+ echo "$int connected" || echo "$int disconnected"
+}
+
+groups() {
+ cur=`xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}'`
+ tot=`xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}'`
+
+ for w in `seq 0 $((cur - 1))`; do line="${line}="; done
+ line="${line}|"
+ for w in `seq $((cur + 2)) $tot`; do line="${line}="; done
+ echo $line
+}
+
+nowplaying() {
+ cur=`mpc current`
+ # this line allow to choose whether the output will scroll or not
+ test "$1" = "scroll" && PARSER='skroll -n20 -d0.5 -r' || PARSER='cat'
+ test -n "$cur" && $PARSER <<< $cur || echo "- stopped -"
+}
+
+# This loop will fill a buffer with our infos, and output it to stdout.
+while :; do
+ buf=""
+ buf="${buf} %{F#ffffff}[$(groups)]"
+#buf="${buf} %{c}NET: $(network) -"
+ buf="${buf} %{c}%{F#b35050}$(nowplaying)"
+ buf="${buf} %{r}%{F#ffffff}CPU: $(cpuload)% | "
+ buf="${buf} RAM: $(memused)% |"
+#buf="${buf} VOL: $(volume)"
+ buf="${buf} $(clock)"
+
+ echo $buf
+ # use `nowplaying scroll` to get a scrolling output!
+ sleep 1 # The HUD will be updated every second
+ done
--- /dev/null
+#!/bin/sh
+xrandr --output DVI-I-0 --off --output DVI-I-1 --off --output HDMI-0 --mode 1920x1080 --pos 0x511 --rotate normal --output DP-0 --mode 1920x1080 --pos 1920x0 --rotate left --output DP-1 --off --output DVI-D-0 --off
--- /dev/null
+#!/bin/bash
+qtwebflix
--- /dev/null
+#!/bin/bash
+
+cd ~/pictures/wallpapers/vaporwave/
+#feh --bg-scale bust.jpg 156890-free-download-vaporwave-iphone-wallpaper-1080x1920-notebook.jpg
+feh --bg-scale moonscape.jpg purple-rain-vert.jpg
--- /dev/null
+#!/bin/bash
+
+mgba ~/games/gba/Pokemon\ -\ Emerald\ Version\ \(U\).gba
--- /dev/null
+#!/bin/bash
+
+while(true)
+ xdotool click 2
--- /dev/null
+#!/bin/sh
+xrandr --output DisplayPort-0 --off --output DisplayPort-1 --off --output DisplayPort-2 --mode 1920x1080 --pos 2011x0 --rotate right --output HDMI-A-0 --primary --mode 1920x1080 --pos 0x673 --rotate normal
--- /dev/null
+xset s noblank && xset -dpms
--- /dev/null
+#!/bin/bash
+
+import /tmp/ss.png
--- /dev/null
+#!/bin/sh
+
+err() { echo "Usage:
+ tag [OPTIONS] file
+Options:
+ -a: artist/author
+ -t: song/chapter title
+ -A: album/book title
+ -n: track/chapter number
+ -N: total number of tracks/chapters
+ -d: year of publication
+ -g: genre
+ -c: comment
+You will be prompted for title, artist, album and track if not given." && exit 1 ;}
+
+while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
+ a) artist="${OPTARG}" ;;
+ t) title="${OPTARG}" ;;
+ A) album="${OPTARG}" ;;
+ n) track="${OPTARG}" ;;
+ N) total="${OPTARG}" ;;
+ d) date="${OPTARG}" ;;
+ g) genre="${OPTARG}" ;;
+ c) comment="${OPTARG}" ;;
+ f) file="${OPTARG}" ;;
+ *) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
+esac done
+
+shift $((OPTIND - 1))
+
+file="$1"
+
+[ ! -f "$file" ] && echo "Provide file to tag." && err
+
+[ -z "$title" ] && echo "Enter a title." && read -r title
+[ -z "$artist" ] && echo "Enter an artist." && read -r artist
+[ -z "$album" ] && echo "Enter an album." && read -r album
+[ -z "$track" ] && echo "Enter a track number." && read -r track
+
+case "$file" in
+ *.ogg) echo "Title=$title
+Artist=$artist
+Album=$album
+Track=$track
+Total=$total
+Date=$date
+Genre=$genre
+Comment=$comment" | vorbiscomment -w "$file" ;;
+ *.opus) echo "Title=$title
+Artist=$artist
+Album=$album
+Track=$track
+Total=$total
+Date=$date
+Genre=$genre
+Comment=$comment" | opustags -i -S "$file" ;;
+ *.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
+ *) echo "File type not implemented yet." ;;
+esac
--- /dev/null
+#!/bin/bash
+cd ~/scripts;
+nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }" && ./mm.sh
--- /dev/null
+#!/bin/bash
+
+mupdf ~/documents/books/The\ C\ Programming\ Language\ -\ 2nd\ Edition\ -\ Ritchie\ Kernighan.pdf
--- /dev/null
+ #!/bin/bash
+
+
+ while read pkg; do
+
+ mapfile -t files < <(pacman -Qlq $pkg | grep -v /$)
+
+ grep -Fq libstdc++.so.6 "${files[@]}" 2>/dev/null && echo $pkg
+
+ done < <(pacman -Qmq)
--- /dev/null
+fast_chr() {
+ local __octal
+ local __char
+ printf -v __octal '%03o' $1
+ printf -v __char \\$__octal
+ REPLY=$__char
+}
+
+function unichr {
+ local c=$1 # Ordinal of char
+ local l=0 # Byte ctr
+ local o=63 # Ceiling
+ local p=128 # Accum. bits
+ local s='' # Output string
+
+ (( c < 0x80 )) && { fast_chr "$c"; echo -n "$REPLY"; return; }
+
+ while (( c > o )); do
+ fast_chr $(( t = 0x80 | c & 0x3f ))
+ s="$REPLY$s"
+ (( c >>= 6, l++, p += o+1, o>>=1 ))
+ done
+
+ fast_chr $(( t = p | c ))
+ echo -n "$REPLY$s"
+}
+
+## test harness
+for (( i=0x0000; i<0xE000; i++ )); do
+ unichr $i
+ done
--- /dev/null
+#!/bin/bash
+ext="${1##*.}"
+mpvFiles="mkv mp4 gif"
+fehFiles="png jpg jpeg jpe"
+wgetFiles="mp3 flac opus mp3?source=feed pdf"
+
+if echo $fehFiles | grep -w $ext > /dev/null; then
+ nohup feh "$1" >/dev/null &
+elif echo $mpvFiles | grep -w $ext > /dev/null; then
+ nohup mpv --loop --quiet "$1" > /dev/null &
+elif echo $wgetFiles | grep -w $ext > /dev/null; then
+ nohup wget "$1" >/dev/null &
+else
+ #nohup $BROWSER "$1" >/dev/null &
+ nohup surf "$1" >/dev/null &
+fi
--- /dev/null
+#!/bin/bash
+# whoneeds package : shows explicitly installed packages that require some package
+
+# we use associative arrays to get uniqueness for "free"
+typeset -A root_packages
+typeset -A walked_nodes
+query="$1"
+
+function walk_nodes () {
+ local package="$1"
+
+ # if we've walked this node before, skip. This drastically
+ # reduces overhead for a relatively cheap operation
+ [[ "${walked_nodes[$package]}" -eq 1 ]] && return 0
+ walked_nodes["$package"]=1
+
+ # we do this so that we can make a single call to pacman
+ # to get both bits of information that we require
+ result=( $(LC_ALL=c pacman -Qi "$package" | awk -F':' \
+ 'BEGIN { tag = ""; dependents = ""; explicit = 0 }
+ {
+ # since the formatting of the pacman output is more for human
+ # consumption than programmatic, we find ourselves with the following need.
+ # if we have two fields, then we know we have a proper identifier on the line
+ # so we store the identifier as a current tag
+ # All identifier checks are made against the current tag, which allows us
+ # to deal with instances where "Required By" spans lines
+ if (NF == 2) { tag = $1 }
+ if (tag ~ /^Required By[ ]*$/) { dependents = dependents $(NF) }
+ if ($1 ~ /^Install Reason $/ && $2 ~/^ Explicitly installed/) { explicit = 1 }
+ }
+ END { print explicit,dependents}') )
+
+ # and if we hit an issue retrieving package information
+ if [[ ${#result[*]} -lt 2 ]]; then
+ echo "error: could not get information on $package" 1>&2
+ exit 3
+ fi
+ if [[ ${result[0]} -eq 1 ]]; then
+ # we found an explicitly installed package that relies on
+ # the original query. Add it to our array, provided it isn't
+ # the original query, as that would be useless information
+ [[ "$query" != "$package" ]] && root_packages["$package"]=1
+ fi
+ if [[ "${result[1]}" != "None" ]]; then
+ # iterate over our 'Required By:' packages
+ dependents="${result[@]:1:${#result[*]}}"
+ for i in "$dependents"; do
+ walk_nodes "$i"
+ done
+ fi
+}
+
+if [ $# -ne 1 ]; then
+ echo "error: unexpected number of arguments" 1>&2
+ echo "Usage: $(basename $0) <package-name>"
+ exit 2
+fi
+
+walk_nodes "$1"
+echo "Packages that depend on [$query]"
+if [[ -n "${!root_packages[*]}" ]]; then
+ for pkg in "${!root_packages[@]}"; do
+ echo " $pkg"
+ done | sort
+ exit 0
+fi
+echo " None"
+exit 1
+
+# vim: set ts=4 sw=4 et:
+