scripts folder moved to ~/.scripts

This commit is contained in:
Luke
2018-02-20 14:29:53 -07:00
parent f1366ff22b
commit 838eeec9ac
23 changed files with 6 additions and 6 deletions

18
.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
.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

2
.scripts/camtoggle Executable file
View File

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

1
.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
.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 ~/.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

30
.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

10
.scripts/folders Normal file
View File

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

93
.scripts/offlineimap-daemon.py Executable file
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
.scripts/remaps Normal file
View File

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

24
.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

22
.scripts/screencast_alsa.sh Executable file
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

24
.scripts/screencast_pulse.sh Executable file
View File

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

62
.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!"

2
.scripts/spawndl Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
i3 exec "st -n dl -e youtube-dl $1"

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

4
.scripts/tmuxinit Executable file
View File

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

7
.scripts/transmission.sh Executable file
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
.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
.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
.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