"first" commit, preparing for LARBS 2.0

This commit is contained in:
Luke
2018-01-21 18:29:48 -07:00
parent 68bd2acdc8
commit 50adee4e79
76 changed files with 9372 additions and 2 deletions

18
.config/Scripts/audio_alsa.sh Executable file
View File

@@ -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

18
.config/Scripts/audio_pulse.sh Executable file
View File

@@ -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

1
.config/Scripts/clear.sh Executable file
View File

@@ -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

17
.config/Scripts/configs Normal file
View File

@@ -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 ~/.config/Scripts/folders
cfc ~/.config/Scripts/configs
cft ~/.config/termite/config
cfT ~/.tmux.conf
eb ~/Documents/LaTeX/uni.bib
cv ~/Documents/LaTeX/cv.tex
cfa ~/.config/mutt/aliases
cfp ~/.config/polybar/config
cfd ~/.Xdefaults

30
.config/Scripts/extract Executable file
View File

@@ -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

View File

@@ -0,0 +1,13 @@
#!/bin/bash
#Flashes the active window.
#Requires transset-df and a composite manager, like xcompmgr.
transset -a -m 0
sleep .1
transset -a -x 1
sleep .1
transset -a -m 0
sleep .1
transset -a -x 1

10
.config/Scripts/folders Normal file
View File

@@ -0,0 +1,10 @@
h ~
d ~/Documents
D ~/Downloads
pp ~/Pictures
vv ~/Videos
m ~/Music
b ~/Books
s ~/.config/Scripts
r /
cf ~/.config

View File

@@ -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()

View File

@@ -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

1
.config/Scripts/remaps Normal file
View File

@@ -0,0 +1 @@
keycode 135 = Super_R NoSymbol Super_R

169
.config/Scripts/resize-font Normal file
View File

@@ -0,0 +1,169 @@
# vim:ft=perl:fenc=utf-8
# Copyright (c) 2009-, Simon Lundström <simmel@soy.se>
# Copyright (c) 2014 Maarten de Vries <maarten@de-vri.es>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# Usage:
# Set your font in ~/.Xresources:
# urxvt.font: xft:Inconsolata:pixelsize=12
# to set it with pixels or
# urxvt.font: xft:Inconsolata:size=12
# to set it with points.
# And re-bind some keymappings (if you want, below are the defaults):
# URxvt.keysym.C-minus: resize-font:smaller
# URxvt.keysym.C-plus: resize-font:bigger
# URxvt.keysym.C-equal: resize-font:reset
# URxvt.keysym.C-question: resize-font:show
#
my @fonts = (
{'name' => 'font', 'code' => 710},
{'name' => 'boldFont', 'code' => 711},
{'name' => 'italicFont', 'code' => 712},
{'name' => 'boldItalicFont', 'code' => 713},
);
my @fixed = qw(4x6 5x7 5x8 6x9 6x10 6x12 6x13 7x13 7x14 8x13 8x16 9x15 9x18 10x20 12x24);
sub on_start {
my ($self) = @_;
foreach (@fonts) {
$_->{'default'} = $self->resource($_->{'name'});
}
}
sub on_init {
my ($self) = @_;
my $commands = {
"smaller" => "C-minus",
"bigger" => "C-plus",
"reset" => "C-equal",
"show" => "C-question",
};
bind_hotkeys($self, $commands);
()
}
sub bind_hotkeys {
my ($self, $commands) = @_;
for (keys %$commands) {
my $hotkey = $$commands{$_};
my $hotkey_bound = $self->{'term'}->x_resource("keysym.$hotkey");
if (!defined($hotkey_bound) ) {
# Support old-style key bindings
if ($self->x_resource("%.$_")) {
$hotkey = $self->x_resource("%.$_");
}
# FIXME If we're bound to a keysym, don't bind the default.
$self->bind_action($hotkey, "%:$_") or
warn "unable to register '$hotkey' as hotkey for $_";
}
else {
if ($hotkey_bound !~ /^resize-font:/) {
warn "Hotkey $$commands{$_} already bound to $hotkey_bound, not binding to resize-font:$_ by default.";
}
}
}
}
sub on_action {
my ($self, $string) = @_;
my $regex = qr"(?!pixelsize=)(\d+)";
if ($string eq "bigger") {
foreach (@fonts) {
next if not defined($_->{'default'});
update_font_size($self, $_, +2);
}
}
elsif ($string eq "smaller") {
foreach (@fonts) {
next if not defined($_->{'default'});
update_font_size($self, $_, -2);
}
}
elsif ($string eq "reset") {
foreach (@fonts) {
next if not defined($_->{'default'});
set_font($self, $_, $_->{'default'});
}
}
elsif ($string eq "show") {
my $term = $self->{'term'};
$term->{'resize-font'}{'overlay'} = {
ov => $term->overlay_simple(0, -1, format_font_info($self)),
to => urxvt::timer
->new
->start(urxvt::NOW + 1)
->cb(sub {
delete $term->{'resize-font'}{'overlay'};
}),
};
}
()
}
sub get_font {
my ($self, $name) = @_;
return $self->resource($name);
}
sub set_font {
my ($self, $font, $new) = @_;
$self->cmd_parse(sprintf("\33]%d;%s\007", $font->{'code'}, $new));
}
sub update_font_size {
my ($self, $font, $delta) = @_;
my $regex = qr"(?<=size=)(\d+)";
my $current = get_font($self, $font->{'name'});
my ($index) = grep { $fixed[$_] eq $current } 0..$#fixed;
if ($index or $index eq 0) {
my $inc = $delta / abs($delta);
$index += $inc;
if ($index < 0) { $index = 0; }
if ($index > $#fixed) { $index = $#fixed; }
$current = $fixed[$index];
}
else {
$current =~ s/$regex/$1+$delta/ge;
}
set_font($self, $font, $current);
}
sub format_font_info {
my ($self) = @_;
my $width = 0;
foreach (@fonts) {
my $length = length($_->{'name'});
$width = $length > $width ? $length : $width;
}
++$width;
my $info = '';
foreach (@fonts) {
$info .= sprintf("%-${width}s %s\n", $_->{'name'} . ':', get_font($self, $_->{'name'}));
}
return $info;
}

24
.config/Scripts/screen.sh Executable file
View File

@@ -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

View File

@@ -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

View File

@@ -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 \
-f alsa -i default \
-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 \

62
.config/Scripts/shortcuts.sh Executable file
View File

@@ -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!"

7
.config/Scripts/speedvid.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
base=$(basename $1)
ext="${base##*.}"
base="${base%.*}"
ffmpeg -i $1 -vf "setpts=$2*PTS" -an $base'_sped.'$ext

View File

@@ -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

21
.config/Scripts/video.sh Executable file
View File

@@ -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

23
.config/Scripts/webview Executable file
View File

@@ -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

4
.config/Scripts/welcome Executable file
View File

@@ -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