summaryrefslogtreecommitdiffstats
path: root/.scripts
diff options
context:
space:
mode:
Diffstat (limited to '.scripts')
-rw-r--r--.scripts/SCRIPTS.md30
-rwxr-xr-x.scripts/compiler4
-rwxr-xr-x.scripts/kb-lights.py35
-rwxr-xr-x.scripts/linkhandler8
-rwxr-xr-x.scripts/lmc8
-rw-r--r--.scripts/lock.pngbin0 -> 7897 bytes
-rwxr-xr-x.scripts/lockscreen37
-rwxr-xr-x.scripts/opout12
-rwxr-xr-x.scripts/pauseallmpv4
-rwxr-xr-x.scripts/texclear8
-rwxr-xr-x.scripts/toggletouchpad4
-rwxr-xr-x.scripts/unix25
12 files changed, 171 insertions, 4 deletions
diff --git a/.scripts/SCRIPTS.md b/.scripts/SCRIPTS.md
index 521450b..42a866e 100644
--- a/.scripts/SCRIPTS.md
+++ b/.scripts/SCRIPTS.md
@@ -11,6 +11,10 @@ Starts/kills /dev/video0 webcam. Placed in bottom right by default.
## `compiler`
Compiles a markdown, R markdown or LaTeX document with the approriate command.
+Will also run `make && sudo make install` if in a `config.h` file.
+Otherwise it will create a sent presentation.
+This can be thought of a general output handler.
+I have it bound to `<leader>c` in vim.
## `crontog`
Turns off/on all user cronjobs.
@@ -69,6 +73,10 @@ i3blocks module. Shows volume percentage or mute notification.
## `i3weather`
i3blocks module. Gets weather forcast from wttr.in and returns today's precipitation chance (☔), daily low (❄️) and daily high (☀️).
+## `kb-lights.py`
+A Python 3 script which will increase or decrease keyboard lights when given
+either a `+` or `-` argument.
+
## `killrecording`
End a recording started by `dmenurecord` the proper way.
@@ -78,12 +86,30 @@ The automatic link handler used by `newsboat` and other programs. Urls of video
## `lmc`
A music controller that simplifies music/audio management and improves the interface with i3blocks. Check inside to see what it does. This is what i3 audio/music commands run by default. If you use a difference music system or ALSA, you can change this script rather than changing all the shortcuts in different places.
+## `lockscreen`
+The screen locker. Gives a confirm prompt and if user says yes, all audio will
+be paused and the screen will be distorted and locked and screen will soon time out. User must insert password to unlock.
+
## `musstuff`
Some old notes and commands on deleted music shortcuts.
+## `opout`
+"Open output", opens the corresponding `.pdf` file if run on a `.md`, `.tex` or
+`.rmd` file, or if given an `.html` file, will open it in the browser.
+Bound to `<leader>p` in my vim config to reveal typical output.
+
+## `pauseallmpv`
+Pauses all mpv instances by sending the `,` key to each. Used by several
+scripts, but can be used alone as well.
+
## `polybar_launch`
For `polybar` users. Launches `polybar` on every screen. Should be run in the i3 config.
+## `popweather`
+The script called by clicking on the i3 weather module. Brings up the forecast
+from `http://wttr.in` and waits for input to prevent immediate closing of
+spawned window.
+
## `prompt`
Gives a Yes/No prompt to a question given as an argument. Used by numerous bindings like `mod+shift+x`, `mod+shift+backspace` and `mod+shift+escape`.
@@ -102,6 +128,10 @@ Remove all `.tex` related build files. This is run by my vim when I stop editing
## `tmuxinit`
The startup script for the dropdown terminal (toggleable with `mod+u`). Either attaches to an existing tmux session or begins a new one.
+## `toggletouchpad`
+As the name suggests, turns off TouchPad if on, and turns it on if off.
+Requires `xf86-input-synaptics`.
+
## `tpb`
Search Pirate Bay for the certain search terms given as arguments.
diff --git a/.scripts/compiler b/.scripts/compiler
index 73ce5bc..919b428 100755
--- a/.scripts/compiler
+++ b/.scripts/compiler
@@ -9,9 +9,12 @@
# config.h files: (For suckless utils) recompiles and installs program.
# all others: run `sent` to show a presentation
+oridir=$(pwd)
+
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
+cd $dir
textype() { \
command="pdflatex"
@@ -30,3 +33,4 @@ case "$file" in
*config.h) make && sudo make install ;;
*) sent "$file" 2>/dev/null & ;;
esac
+cd $oridir
diff --git a/.scripts/kb-lights.py b/.scripts/kb-lights.py
new file mode 100755
index 0000000..f492de0
--- /dev/null
+++ b/.scripts/kb-lights.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+# coding: utf-8
+
+from sys import argv
+import dbus
+
+
+def kb_light_set(delta):
+ bus = dbus.SystemBus()
+ kbd_backlight_proxy = bus.get_object('org.freedesktop.UPower', '/org/freedesktop/UPower/KbdBacklight')
+ kbd_backlight = dbus.Interface(kbd_backlight_proxy, 'org.freedesktop.UPower.KbdBacklight')
+
+ current = kbd_backlight.GetBrightness()
+ maximum = kbd_backlight.GetMaxBrightness()
+ new = max(0, current + delta)
+
+ if 0 <= new <= maximum:
+ current = new
+ kbd_backlight.SetBrightness(current)
+
+ # Return current backlight level percentage
+ return 100 * current / maximum
+
+if __name__ == '__main__':
+ if len(argv[1:]) == 1:
+ if argv[1] == "--up" or argv[1] == "+":
+ # ./kb-light.py (+|--up) to increment
+ print(kb_light_set(1))
+ elif argv[1] == "--down" or argv[1] == "-":
+ # ./kb-light.py (-|--down) to decrement
+ print(kb_light_set(-1))
+ else:
+ print("Unknown argument:", argv[1])
+ else:
+ print("Script takes exactly one argument.", len(argv[1:]), "arguments provided.")
diff --git a/.scripts/linkhandler b/.scripts/linkhandler
index 20b1bd3..94fdd83 100755
--- a/.scripts/linkhandler
+++ b/.scripts/linkhandler
@@ -6,11 +6,17 @@
# if a music file or pdf, it will download,
# otherwise it opens link in browser.
+scihub="http://sci-hub.tw/"
+
# List of sites that will be opened in mpv.
vidsites="youtube.com
\|hooktube.com
\|bitchute.com
"
+
+# List of academic sites whose pdfs can be dled via sci-hub.
+academic="springer.com"
+
ext="${1##*.}"
mpvFiles="mkv mp4 gif webm"
fehFiles="png jpg jpeg jpe"
@@ -24,6 +30,8 @@ elif echo $wgetFiles | grep -w $ext > /dev/null; then
wget "$1" >/dev/null & disown
elif echo "$@" | grep "$vidsites">/dev/null; then
setsid nohup mpv -quiet "$1" > /dev/null & disown
+elif echo "$@" | grep "$academic">/dev/null; then
+ curl -sO $(curl -s "$scihub""$@" | grep location.href | grep -o http.*pdf) & disown
else
setsid nohup $BROWSER "$1" 2>/dev/null & disown
fi
diff --git a/.scripts/lmc b/.scripts/lmc
index 83a08db..37bd958 100755
--- a/.scripts/lmc
+++ b/.scripts/lmc
@@ -1,7 +1,10 @@
#!/bin/bash
+# A general audio interface for LARBS.
+
newvol="pkill -RTMIN+10 i3blocks"
-newmpd="pkill -RTMIN+11 i3blocks"
+# Uncomment if i3mpdupdate isn't running:
+#newmpd="pkill -RTMIN+11 i3blocks"
case "$1" in
"up") pamixer --allow-boost -i "$2" ; $newvol ;;
@@ -9,11 +12,10 @@ case "$1" in
"mute") pamixer --allow-boost -t ; $newvol ;;
"truemute") pamixer --allow-boost -m ; $newvol ;;
"toggle") mpc toggle ; $newmpd ;;
- "pause") mpc pause ; $newmpd ;;
+ "pause") mpc pause ; $newmpd ; pauseallmpv ;;
"forward") mpc seek +"$2" ; $newmpd ;;
"back") mpc seek -"$2" ; $newmpd ;;
"next") mpc next ; $newmpd ;;
"prev") mpc prev ; $newmpd ;;
"replay") mpc seek 0% ; $newmpd ;;
esac
-exit
diff --git a/.scripts/lock.png b/.scripts/lock.png
new file mode 100644
index 0000000..b09875d
--- /dev/null
+++ b/.scripts/lock.png
Binary files differ
diff --git a/.scripts/lockscreen b/.scripts/lockscreen
new file mode 100755
index 0000000..eba33d3
--- /dev/null
+++ b/.scripts/lockscreen
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Approximate timeout rate in milliseconds (checked every 5 seconds).
+timeout="10000"
+
+# Take a screenshot of every screen available:
+scrot -m -z /tmp/lock.png
+xdpyinfo -ext XINERAMA | sed '/^ head #/!d;s///' |
+{
+ cmd="convert /tmp/lock.png"
+ cmdend=""
+ while IFS=' :x@,' read i w h x y; do
+ cmd+=" -region ${w}x$h+$x+$y -paint 1 -swirl 360"
+ xc=$((x+(w/2)-79))
+ yc=$((y+(h/2)-79))
+ cmdend+=" ~/.scripts/lock.png -geometry +${xc}+${yc} -composite -matte"
+ done
+ cmd+="${cmdend} /tmp/screen.png"
+
+ eval $cmd
+} &
+
+prompt "Are you sure you want to lock the computer?" "" || exit
+
+# Pause music (mocp and mpd):
+mocp -P
+mpc pause
+pauseallmpv
+
+# Lock it up!
+i3lock -e -f -c 000000 -i /tmp/screen.png
+
+# If still locked after $timeout milliseconds, turn off screen.
+while [[ $(pgrep -x i3lock) ]]; do
+ [[ $timeout -lt $(xssstate -i) ]] && xset dpms force off
+ sleep 5
+done
diff --git a/.scripts/opout b/.scripts/opout
new file mode 100755
index 0000000..28dcafd
--- /dev/null
+++ b/.scripts/opout
@@ -0,0 +1,12 @@
+#!/bin/bash
+# opout: "open output": A general handler for opening a file's intended output.
+# I find this useful especially running from vim.
+
+filename=$(readlink -f "$1")
+ext="${filename##*.}"
+filename="${filename%.*}"
+
+case "$ext" in
+ tex|md|rmd) zathura $filename.pdf & ;;
+ html) $BROWSER --new-window $filename.html & ;;
+esac
diff --git a/.scripts/pauseallmpv b/.scripts/pauseallmpv
new file mode 100755
index 0000000..b24f448
--- /dev/null
+++ b/.scripts/pauseallmpv
@@ -0,0 +1,4 @@
+#!/bin/bash
+# Sends a , key to all mpv instances, pausing them at the last frame.
+
+xdotool search --class mpv | xargs -I % xdotool key --window % comma
diff --git a/.scripts/texclear b/.scripts/texclear
index 9951e27..4f53fc6 100755
--- a/.scripts/texclear
+++ b/.scripts/texclear
@@ -3,4 +3,10 @@
# Clears the build files of a LaTeX/XeLaTeX build.
# I have vim run this file whenever I exit a .tex file.
-find . -maxdepth 1 -regextype gnu-awk -regex "^.*\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\(busy\)|lof|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)" -delete
+[[ "$1" == *.tex ]] || exit
+
+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|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)" -delete
diff --git a/.scripts/toggletouchpad b/.scripts/toggletouchpad
new file mode 100755
index 0000000..bbb4110
--- /dev/null
+++ b/.scripts/toggletouchpad
@@ -0,0 +1,4 @@
+#!/bin/bash
+# Toggle touchpad. Requires xf86-input-synaptics.
+(synclient | grep TouchpadOff.*1 && synclient TouchpadOff=0)>/dev/null && echo "TouchPad reactivated." && exit
+synclient TouchpadOff=1 && echo "TouchPad deactivated."
diff --git a/.scripts/unix b/.scripts/unix
new file mode 100755
index 0000000..14d7ef0
--- /dev/null
+++ b/.scripts/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▓▇▌//&;% / /
+ / / / %//%/¾½´▌▃▄▄▄▄▃▃▐¶\/& /
+ </ /</%//`▓!%▓%╣[38;5;255;╣WY<Y)y&/`\
+ / / %/%//</%//\i7; ╠N>)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