summaryrefslogtreecommitdiffstats
path: root/.scripts
diff options
context:
space:
mode:
Diffstat (limited to '.scripts')
-rwxr-xr-x.scripts/audio_alsa.sh18
-rwxr-xr-x.scripts/audio_pulse.sh18
-rwxr-xr-x.scripts/camtoggle2
-rwxr-xr-x.scripts/clear.sh1
-rw-r--r--.scripts/configs17
-rwxr-xr-x.scripts/extract30
-rw-r--r--.scripts/folders10
-rwxr-xr-x.scripts/offlineimap-daemon.py93
-rwxr-xr-x.scripts/offlineimap-daemonctl.sh40
-rw-r--r--.scripts/remaps1
-rwxr-xr-x.scripts/screen.sh24
-rwxr-xr-x.scripts/screencast_alsa.sh22
-rwxr-xr-x.scripts/screencast_pulse.sh24
-rwxr-xr-x.scripts/shortcuts.sh62
-rwxr-xr-x.scripts/spawndl2
-rwxr-xr-x.scripts/speedvid.sh7
-rwxr-xr-x.scripts/tmuxinit4
-rwxr-xr-x.scripts/transmission.sh7
-rwxr-xr-x.scripts/video.sh21
-rwxr-xr-x.scripts/webview23
-rwxr-xr-x.scripts/welcome4
21 files changed, 430 insertions, 0 deletions
diff --git a/.scripts/audio_alsa.sh b/.scripts/audio_alsa.sh
new file mode 100755
index 0000000..cda07a2
--- /dev/null
+++ b/.scripts/audio_alsa.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+#This is the ffmpeg command that the screencast shortcut in i3 will run.
+
+#Picks a file name for the output file based on availability:
+
+while [[ -f $HOME/audio$n.flac ]]
+do
+ n=$((n+1))
+done
+filename="$HOME/audio$n.flac"
+
+#The actual ffmpeg command:
+
+ffmpeg -y \
+ -f alsa -ar 44100 -i hw:1 \
+ $filename
+
diff --git a/.scripts/audio_pulse.sh b/.scripts/audio_pulse.sh
new file mode 100755
index 0000000..21e46ea
--- /dev/null
+++ b/.scripts/audio_pulse.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+#This is the ffmpeg command that the audio shortcut in i3 will run.
+
+#Picks a file name for the output file based on availability:
+
+while [[ -f $HOME/audio$n.flac ]]
+do
+ n=$((n+1))
+done
+filename="$HOME/audio$n.flac"
+
+#The actual ffmpeg command:
+
+ffmpeg \
+-f alsa -i default \
+-c:a flac \
+$filename
diff --git a/.scripts/camtoggle b/.scripts/camtoggle
new file mode 100755
index 0000000..9a7879c
--- /dev/null
+++ b/.scripts/camtoggle
@@ -0,0 +1,2 @@
+#!/bin/bash
+pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --geometry=-0-0 --autofit=30% /dev/video0
diff --git a/.scripts/clear.sh b/.scripts/clear.sh
new file mode 100755
index 0000000..af13a73
--- /dev/null
+++ b/.scripts/clear.sh
@@ -0,0 +1 @@
+find . -maxdepth 1 -regextype gnu-awk -regex "^.*\.(pyc|p yo|bak|swp|aux|log|lof|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)" -delete
diff --git a/.scripts/configs b/.scripts/configs
new file mode 100644
index 0000000..fcc0360
--- /dev/null
+++ b/.scripts/configs
@@ -0,0 +1,17 @@
+cfb ~/.bashrc
+cfz ~/.zshrc
+cfv ~/.vimrc
+cfr ~/.config/ranger/rc.conf
+cfi ~/.config/i3/config
+cfq ~/.config/qutebrowser/config.py
+cfm ~/.config/mutt/muttrc
+cfM ~/.config/moc/keymap
+cff ~/.scripts/folders
+cfc ~/.scripts/configs
+cft ~/.config/termite/config
+cfT ~/.tmux.conf
+eb ~/Documents/LaTeX/uni.bib
+cv ~/Documents/LaTeX/cv.tex
+cfa ~/.config/mutt/etc/aliases
+cfp ~/.config/polybar/config
+cfd ~/.Xdefaults
diff --git a/.scripts/extract b/.scripts/extract
new file mode 100755
index 0000000..aaf2911
--- /dev/null
+++ b/.scripts/extract
@@ -0,0 +1,30 @@
+#!/bin/bash
+# there are two different ways this script can work.
+# for the first way, uncomment the two lines after the if and place two '.' in front of the /$1
+# this creates a new directory in the directory where the compressed file is and dumps the content in it
+# for the second way, comment the two lines under the if and place just one '.' in front of the /$1
+# this just dumps the content of the compressed file in the same directory of the compressed file
+if [ -f $1 ] ; then
+ NAME=${1%.*}
+ mkdir $NAME && cd $NAME
+ case $1 in
+ *.tar.bz2) tar xvjf ../$1 ;;
+ *.tar.gz) tar xvzf ../$1 ;;
+ *.tar.xz) tar xvJf ../$1 ;;
+ *.lzma) unlzma ../$1 ;;
+ *.bz2) bunzip2 ../$1 ;;
+ *.rar) unrar x -ad ../$1 ;;
+ *.gz) gunzip ../$1 ;;
+ *.tar) tar xvf ../$1 ;;
+ *.tbz2) tar xvjf ../$1 ;;
+ *.tgz) tar xvzf ../$1 ;;
+ *.zip) unzip ../$1 ;;
+ *.Z) uncompress ../$1 ;;
+ *.7z) 7z x ../$1 ;;
+ *.xz) unxz ../$1 ;;
+ *.exe) cabextract ../$1 ;;
+ *) echo "extract: '$1' - unknown archive method" ;;
+ esac
+else
+echo "$1 - file does not exist"
+ fi
diff --git a/.scripts/folders b/.scripts/folders
new file mode 100644
index 0000000..d84fef6
--- /dev/null
+++ b/.scripts/folders
@@ -0,0 +1,10 @@
+h ~/
+d ~/Documents
+D ~/Downloads
+pp ~/Pictures
+vv ~/Videos
+m ~/Music
+b ~/Books
+s ~/.scripts
+r /
+cf ~/.config
diff --git a/.scripts/offlineimap-daemon.py b/.scripts/offlineimap-daemon.py
new file mode 100755
index 0000000..fea76fc
--- /dev/null
+++ b/.scripts/offlineimap-daemon.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+
+import subprocess
+import signal
+import threading
+import sys
+
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+from gi.repository import GLib
+
+
+class OfflineimapCtl(object):
+ def __init__(self):
+ self.daemon_proc = None
+ self.run_ev = threading.Event()
+ self.run_daemon = False
+
+ def run(self):
+ t = threading.Thread(target=self._watch_daemon, daemon=True)
+ t.start()
+
+ def _watch_daemon(self):
+ while True:
+ self.run_ev.wait()
+ self.run_ev.clear()
+ if self.run_daemon:
+ self.is_running = True
+ print('offlineimap is being started')
+ self._spawn_daemon()
+ print('offlineimap has stopped')
+ self.run_ev.set() # check state and restart if needed
+
+ def _spawn_daemon(self):
+ self.daemon_proc = subprocess.Popen(['offlineimap', '-u', 'basic'], shell=False)
+ self.daemon_proc.wait()
+ self.daemon_proc = None
+
+ def start(self):
+ print('starting offlineimap')
+ self.run_daemon = True
+ self.run_ev.set()
+
+ def stop(self):
+ print('stopping offlineimap')
+ self.run_daemon = False
+ if self.daemon_proc:
+ try:
+ self.daemon_proc.send_signal(signal.SIGUSR2)
+ except OSError:
+ print('Unable to stop offlineimap')
+
+ def restart(self):
+ print('restarting offlineimap')
+ if self.run_daemon:
+ self.stop()
+ self.start()
+
+ def onConnectivityChanged(self, state):
+ # 70 means fully connected
+ if state == 70:
+ self.start()
+ else:
+ self.stop()
+
+def main():
+ oi_ctl = OfflineimapCtl()
+ oi_ctl.run()
+
+ try:
+ bus = dbus.SystemBus(mainloop=DBusGMainLoop())
+ network_manager = bus.get_object(
+ 'org.freedesktop.NetworkManager',
+ '/org/freedesktop/NetworkManager')
+ network = dbus.Interface(network_manager,
+ dbus_interface='org.freedesktop.NetworkManager')
+
+ network.connect_to_signal('StateChanged', oi_ctl.onConnectivityChanged)
+
+ # send current state as first event
+ state = network.state()
+ oi_ctl.onConnectivityChanged(state)
+
+ except dbus.exceptions.DBusException:
+ print('Unable to connect to dbus')
+ sys.exit(3)
+
+ # start receiving events from dbus
+ loop = GLib.MainLoop()
+ loop.run()
+
+if __name__ == '__main__':
+ main()
diff --git a/.scripts/offlineimap-daemonctl.sh b/.scripts/offlineimap-daemonctl.sh
new file mode 100755
index 0000000..18daf3d
--- /dev/null
+++ b/.scripts/offlineimap-daemonctl.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# this script runs offline imap as daemon (configured to check periodically)
+
+LOG=~/.offlineimap/sync.log
+PIDFILE=~/.offlineimap/pid
+
+# if not present on PATH, those vars must point to proper locations
+THIS_SCRIPT=offlineimap-daemonctl.sh
+PYTHON_DAEMON=offlineimap-daemon.py
+
+daemon(){
+ $PYTHON_DAEMON 2>&1 |
+ # add timestamps to logs
+ (while read line; do
+ echo `date` "$line" >> $LOG
+ done)
+}
+
+stop(){
+ kill -USR2 `cat $PIDFILE`
+}
+
+refresh(){
+ kill -USR1 `cat $PIDFILE`
+}
+
+case "$1" in
+ '--daemon' | '-d' )
+ nohup $THIS_SCRIPT < /dev/null > /dev/null 2>&1 &
+ ;;
+ '--kill' | '-k' )
+ stop
+ ;;
+ '--refresh' | '-r' )
+ refresh
+ ;;
+ * )
+ daemon
+ ;;
+esac \ No newline at end of file
diff --git a/.scripts/remaps b/.scripts/remaps
new file mode 100644
index 0000000..aa5a5f2
--- /dev/null
+++ b/.scripts/remaps
@@ -0,0 +1 @@
+keycode 135 = Super_R NoSymbol Super_R
diff --git a/.scripts/screen.sh b/.scripts/screen.sh
new file mode 100755
index 0000000..03a8e79
--- /dev/null
+++ b/.scripts/screen.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#Feed this script either:
+# "l" for laptop screen only,
+# "v" for vga screen only,
+# or "d" for dual vga/laptop.
+
+d() { if [[ $(xrandr -q | grep VGA1\ con) ]]
+ then param $1
+ else echo "No VGA input detected."
+ fi ;}
+dual() { xrandr --output LVDS1 --auto --output VGA1 --auto --right-of LVDS1 ;}
+laptop() { xrandr --output LVDS1 --auto --output VGA1 --off ;}
+vga() { xrandr --output VGA1 --auto --output LVDS1 --off ;}
+#mirror() { xrandr --addmode VGA1 $lapres && xrandr --output LVDS1 --mode $lapres --output VGA1 --mode $lapres ;}
+
+param() {
+case $1 in
+ d) dual ;;
+ v) vga ;;
+ l) laptop ;;
+ *) echo -e "Invalid parameter. Add one of the following:\n\"d\" for dualscreen laptop and VGA.\n\"l\" for laptop only\n\"v\" for VGA only." ;;
+esac ;}
+d $1
diff --git a/.scripts/screencast_alsa.sh b/.scripts/screencast_alsa.sh
new file mode 100755
index 0000000..95c1d5d
--- /dev/null
+++ b/.scripts/screencast_alsa.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+#This is the ffmpeg command that the screencast shortcut in i3 will run.
+
+#Picks a file name for the output file based on availability:
+
+while [[ -f $HOME/screencast$n.mkv ]]
+do
+ n=$((n+1))
+done
+filename="$HOME/screencast$n.mkv"
+
+#The actual ffmpeg command:
+
+ffmpeg -y \
+-f x11grab \
+-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
+-i :0.0 \
+-thread_queue_size 1024 \
+ -f alsa -ar 44100 -i hw:1 \
+ -c:v libx264 -r 30 -c:a flac $filename
+ #-c:v ffvhuff -r 30 -c:a flac $filename
diff --git a/.scripts/screencast_pulse.sh b/.scripts/screencast_pulse.sh
new file mode 100755
index 0000000..8491606
--- /dev/null
+++ b/.scripts/screencast_pulse.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#This is the ffmpeg command that the screencast shortcut in i3 will run.
+
+#Picks a file name for the output file based on availability:
+
+while [[ -f $HOME/screencast$n.mkv ]]
+do
+ n=$((n+1))
+done
+filename="$HOME/screencast$n.mkv"
+
+#The actual ffmpeg command:
+
+ffmpeg -y \
+-f x11grab \
+-framerate 60 \
+-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
+-i :0.0 \
+-f alsa -i default \
+-r 30 \
+ -c:v libx264 -r 30 -c:a flac $filename
+ #-c:v ffvhuff -r 30 -c:a flac $filename
+ #-f pulse -ac 1 -ar 44100 -i default \
diff --git a/.scripts/shortcuts.sh b/.scripts/shortcuts.sh
new file mode 100755
index 0000000..0976e5f
--- /dev/null
+++ b/.scripts/shortcuts.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# Config locations
+folders="$HOME/.config/Scripts/folders"
+configs="$HOME/.config/Scripts/configs"
+
+# Output locations
+bash_shortcuts="$HOME/.bash_shortcuts"
+ranger_shortcuts="$HOME/.config/ranger/shortcuts.conf"
+qute_shortcuts="$HOME/.config/qutebrowser/shortcuts.py"
+
+# Ensuring that output locations are properly sourced
+cat ~/.bashrc | grep "source ~/.bash_shortcuts" >/dev/null &&
+ echo Bashrc already ready. ||
+ (echo "source ~/.bash_shortcuts" >> ~/.bashrc &&
+ echo Bashrc now prepared for shortcuts.)
+
+cat ~/.config/ranger/rc.conf | grep "source ~/.config/ranger/shortcuts.conf" >/dev/null &&
+ echo Rc.conf already ready. ||
+ (echo "source ~/.config/ranger/shortcuts.conf" >> ~/.config/ranger/rc.conf &&
+ echo rc.conf now prepared for shortcuts.)
+
+cat ~/.config/qutebrowser/config.py | grep shortcuts.py >/dev/null &&
+ echo "Qutebrowser's config.py already ready." ||
+ (echo "config.source('shortcuts.py')" >> ~/.config/qutebrowser/config.py &&
+ echo "qutebrowser's config.py now prepared for shortcuts.")
+
+#Delete old shortcuts
+echo "# vim: filetype=sh" > $bash_shortcuts
+echo "# ranger shortcuts" > $ranger_shortcuts
+echo "# qutebrowser shortcuts" > $qute_shortcuts
+
+writeDirs() { echo "alias $1='cd $2 && ls -a'" >> $bash_shortcuts
+ echo "map g$1 cd $2" >> $ranger_shortcuts
+ echo "map t$1 tab_new $2" >> $ranger_shortcuts
+ echo "map m$1 shell mv %s $2" >> $ranger_shortcuts
+ echo "map Y$1 shell cp -r %s $2" >> $ranger_shortcuts
+ echo "config.bind(';$1', 'set downloads.location.directory $2 ;; hint links download')" >> $qute_shortcuts ;}
+
+writeConfs() {
+ echo "alias $1='vim $2'" >> $bash_shortcuts
+ echo "map $1 shell vim $2" >> $ranger_shortcuts ;}
+
+IFS=$'\n'
+set -f
+for line in $(cat "$folders"); do
+ line=$(echo $line | sed 's/#.*//')
+ key=$(echo $line | awk '{print $1}')
+ dir=$(echo $line | awk '{print $2}')
+ [ "$dir" == "" ] || writeDirs $key $dir
+done && echo "Directory shortcuts done."
+
+set -f
+for line in $(cat "$configs");
+do
+ line=$(echo $line | sed 's/#.*//')
+ short=$(echo $line | awk '{print $1}')
+ conf=$(echo $line | awk '{print $2}')
+ [ "$conf" == "" ] || writeConfs $short $conf
+done && echo "Config file shortcuts done."
+
+echo "All done!"
diff --git a/.scripts/spawndl b/.scripts/spawndl
new file mode 100755
index 0000000..a419041
--- /dev/null
+++ b/.scripts/spawndl
@@ -0,0 +1,2 @@
+#!/bin/bash
+i3 exec "st -n dl -e youtube-dl $1"
diff --git a/.scripts/speedvid.sh b/.scripts/speedvid.sh
new file mode 100755
index 0000000..ba3a4f6
--- /dev/null
+++ b/.scripts/speedvid.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+base=$(basename $1)
+ext="${base##*.}"
+base="${base%.*}"
+
+ffmpeg -i $1 -vf "setpts=$2*PTS" -an $base'_sped.'$ext
diff --git a/.scripts/tmuxinit b/.scripts/tmuxinit
new file mode 100755
index 0000000..68a4b86
--- /dev/null
+++ b/.scripts/tmuxinit
@@ -0,0 +1,4 @@
+#!/bin/bash
+# This is the script that i3 runs to either start tmux in
+# the dropdown terminal or log into a previous session.
+tmux a || tmux
diff --git a/.scripts/transmission.sh b/.scripts/transmission.sh
new file mode 100755
index 0000000..794f6bb
--- /dev/null
+++ b/.scripts/transmission.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+if [ -f $(pgrep transmission) ];
+ then
+ urxvt -e transmission-remote-cli
+ else
+ transmission-daemon && urxvt -e transmission-remote-cli
+fi
diff --git a/.scripts/video.sh b/.scripts/video.sh
new file mode 100755
index 0000000..ac3dc5c
--- /dev/null
+++ b/.scripts/video.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#This is the ffmpeg command that the screencast shortcut in i3 will run.
+
+#Picks a file name for the output file based on availability:
+
+while [[ -f $HOME/video$n.mkv ]]
+do
+ n=$((n+1))
+done
+filename="$HOME/video$n.mkv"
+
+
+#The actual ffmpeg command:
+
+ffmpeg \
+-f x11grab \
+-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
+-i :0.0 \
+ -c:v libx264 -qp 0 -r 30 $filename
+ #-c:v ffvhuff -r 30 -c:a flac $filename
diff --git a/.scripts/webview b/.scripts/webview
new file mode 100755
index 0000000..17462fc
--- /dev/null
+++ b/.scripts/webview
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# Feed script a url.
+# Opens the url with xdg-open unless it is an image,
+# in which case it downloads in feh.
+
+ext="${1##*.}"
+mpvFiles="mkv mp4 gif"
+fehFiles="png jpg jpeg jpe"
+wgetFiles="mp3 flac opus mp3?source=feed pdf"
+
+pgrep i3 ifi3="i3 exec"
+
+if echo $fehFiles | grep -w $ext > /dev/null; then
+ nohup feh "$1" >/dev/null &
+#elif [[ "$ext" == "gif" ]]; then
+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 &
+fi
diff --git a/.scripts/welcome b/.scripts/welcome
new file mode 100755
index 0000000..2e33713
--- /dev/null
+++ b/.scripts/welcome
@@ -0,0 +1,4 @@
+#!/bin/bash
+dialog --title "Welcome to LARBS!" --msgbox "If you're new to the system, hold down the Windows key and press F1 for a full tutorial!
+
+(This infobox will greet you at each login until you run the command \"hello-larbs\" in the terminal.)" 10 60