From 838eeec9acdc320bbab24b69db3041e436cdc996 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 20 Feb 2018 14:29:53 -0700 Subject: scripts folder moved to ~/.scripts --- .bash_profile | 2 +- .bashrc | 4 +- .config/Scripts/audio_alsa.sh | 18 ------- .config/Scripts/audio_pulse.sh | 18 ------- .config/Scripts/camtoggle | 2 - .config/Scripts/clear.sh | 1 - .config/Scripts/configs | 17 ------ .config/Scripts/extract | 30 ----------- .config/Scripts/folders | 10 ---- .config/Scripts/offlineimap-daemon.py | 93 -------------------------------- .config/Scripts/offlineimap-daemonctl.sh | 40 -------------- .config/Scripts/remaps | 1 - .config/Scripts/screen.sh | 24 --------- .config/Scripts/screencast_alsa.sh | 22 -------- .config/Scripts/screencast_pulse.sh | 24 --------- .config/Scripts/shortcuts.sh | 62 --------------------- .config/Scripts/spawndl | 2 - .config/Scripts/speedvid.sh | 7 --- .config/Scripts/tmuxinit | 4 -- .config/Scripts/transmission.sh | 7 --- .config/Scripts/video.sh | 21 -------- .config/Scripts/webview | 23 -------- .config/Scripts/welcome | 4 -- .scripts/audio_alsa.sh | 18 +++++++ .scripts/audio_pulse.sh | 18 +++++++ .scripts/camtoggle | 2 + .scripts/clear.sh | 1 + .scripts/configs | 17 ++++++ .scripts/extract | 30 +++++++++++ .scripts/folders | 10 ++++ .scripts/offlineimap-daemon.py | 93 ++++++++++++++++++++++++++++++++ .scripts/offlineimap-daemonctl.sh | 40 ++++++++++++++ .scripts/remaps | 1 + .scripts/screen.sh | 24 +++++++++ .scripts/screencast_alsa.sh | 22 ++++++++ .scripts/screencast_pulse.sh | 24 +++++++++ .scripts/shortcuts.sh | 62 +++++++++++++++++++++ .scripts/spawndl | 2 + .scripts/speedvid.sh | 7 +++ .scripts/tmuxinit | 4 ++ .scripts/transmission.sh | 7 +++ .scripts/video.sh | 21 ++++++++ .scripts/webview | 23 ++++++++ .scripts/welcome | 4 ++ 44 files changed, 433 insertions(+), 433 deletions(-) delete mode 100755 .config/Scripts/audio_alsa.sh delete mode 100755 .config/Scripts/audio_pulse.sh delete mode 100755 .config/Scripts/camtoggle delete mode 100755 .config/Scripts/clear.sh delete mode 100644 .config/Scripts/configs delete mode 100755 .config/Scripts/extract delete mode 100644 .config/Scripts/folders delete mode 100755 .config/Scripts/offlineimap-daemon.py delete mode 100755 .config/Scripts/offlineimap-daemonctl.sh delete mode 100644 .config/Scripts/remaps delete mode 100755 .config/Scripts/screen.sh delete mode 100755 .config/Scripts/screencast_alsa.sh delete mode 100755 .config/Scripts/screencast_pulse.sh delete mode 100755 .config/Scripts/shortcuts.sh delete mode 100755 .config/Scripts/spawndl delete mode 100755 .config/Scripts/speedvid.sh delete mode 100755 .config/Scripts/tmuxinit delete mode 100755 .config/Scripts/transmission.sh delete mode 100755 .config/Scripts/video.sh delete mode 100755 .config/Scripts/webview delete mode 100755 .config/Scripts/welcome create mode 100755 .scripts/audio_alsa.sh create mode 100755 .scripts/audio_pulse.sh create mode 100755 .scripts/camtoggle create mode 100755 .scripts/clear.sh create mode 100644 .scripts/configs create mode 100755 .scripts/extract create mode 100644 .scripts/folders create mode 100755 .scripts/offlineimap-daemon.py create mode 100755 .scripts/offlineimap-daemonctl.sh create mode 100644 .scripts/remaps create mode 100755 .scripts/screen.sh create mode 100755 .scripts/screencast_alsa.sh create mode 100755 .scripts/screencast_pulse.sh create mode 100755 .scripts/shortcuts.sh create mode 100755 .scripts/spawndl create mode 100755 .scripts/speedvid.sh create mode 100755 .scripts/tmuxinit create mode 100755 .scripts/transmission.sh create mode 100755 .scripts/video.sh create mode 100755 .scripts/webview create mode 100755 .scripts/welcome diff --git a/.bash_profile b/.bash_profile index 5bf53be..5bd196d 100644 --- a/.bash_profile +++ b/.bash_profile @@ -4,7 +4,7 @@ [[ -f ~/.bashrc ]] && . ~/.bashrc -export PATH=$PATH:$HOME/.config/Scripts +export PATH=$PATH:$HOME/.scripts export EDITOR="vim" export TERMINAL="st" export BROWSER="qutebrowser" diff --git a/.bashrc b/.bashrc index 5a7a91d..8c8576e 100644 --- a/.bashrc +++ b/.bashrc @@ -51,7 +51,7 @@ alias gitpass="git config --global credential.helper cache" alias tr="transmission-remote" alias mkd="mkdir -pv" alias rf="source ~/.bashrc" -alias ref="~/.config/Scripts/shortcuts.sh && source ~/.bashrc" # Refresh shortcuts manually and reload bashrc +alias ref="shortcuts.sh && source ~/.bashrc" # Refresh shortcuts manually and reload bashrc alias bars="bash ~/.config/polybar/launch.sh" # Run Polybar relaunch script alias bw="wal -i ~/.config/wall.png" # Rerun pywal weath() { curl wttr.in/$1 ;} # Check the weather (give city or leave blank). @@ -74,7 +74,7 @@ alias YT="youtube-viewer" alias ethspeed="speedometer -r enp0s25" alias wifispeed="speedometer -r wlp3s0" alias starwars="telnet towel.blinkenlights.nl" -alias tpbs="clear && figlet -c TPB Search && ~/.config/Scripts/tpb.sh" # Pirate Bay search +alias tpbs="clear && figlet -c TPB Search && tpb.sh" # Pirate Bay search # TeX alias Txa="cp ~/Documents/LaTeX/article.tex" diff --git a/.config/Scripts/audio_alsa.sh b/.config/Scripts/audio_alsa.sh deleted file mode 100755 index cda07a2..0000000 --- a/.config/Scripts/audio_alsa.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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/.config/Scripts/audio_pulse.sh b/.config/Scripts/audio_pulse.sh deleted file mode 100755 index 21e46ea..0000000 --- a/.config/Scripts/audio_pulse.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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/.config/Scripts/camtoggle b/.config/Scripts/camtoggle deleted file mode 100755 index 9a7879c..0000000 --- a/.config/Scripts/camtoggle +++ /dev/null @@ -1,2 +0,0 @@ -#!/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/.config/Scripts/clear.sh b/.config/Scripts/clear.sh deleted file mode 100755 index af13a73..0000000 --- a/.config/Scripts/clear.sh +++ /dev/null @@ -1 +0,0 @@ -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/.config/Scripts/configs b/.config/Scripts/configs deleted file mode 100644 index 58a5542..0000000 --- a/.config/Scripts/configs +++ /dev/null @@ -1,17 +0,0 @@ -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/etc/aliases -cfp ~/.config/polybar/config -cfd ~/.Xdefaults diff --git a/.config/Scripts/extract b/.config/Scripts/extract deleted file mode 100755 index aaf2911..0000000 --- a/.config/Scripts/extract +++ /dev/null @@ -1,30 +0,0 @@ -#!/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/.config/Scripts/folders b/.config/Scripts/folders deleted file mode 100644 index 17a4b8d..0000000 --- a/.config/Scripts/folders +++ /dev/null @@ -1,10 +0,0 @@ -h ~/ -d ~/Documents -D ~/Downloads -pp ~/Pictures -vv ~/Videos -m ~/Music -b ~/Books -s ~/.config/Scripts -r / -cf ~/.config diff --git a/.config/Scripts/offlineimap-daemon.py b/.config/Scripts/offlineimap-daemon.py deleted file mode 100755 index fea76fc..0000000 --- a/.config/Scripts/offlineimap-daemon.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/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/.config/Scripts/offlineimap-daemonctl.sh b/.config/Scripts/offlineimap-daemonctl.sh deleted file mode 100755 index 18daf3d..0000000 --- a/.config/Scripts/offlineimap-daemonctl.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/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/.config/Scripts/remaps b/.config/Scripts/remaps deleted file mode 100644 index aa5a5f2..0000000 --- a/.config/Scripts/remaps +++ /dev/null @@ -1 +0,0 @@ -keycode 135 = Super_R NoSymbol Super_R diff --git a/.config/Scripts/screen.sh b/.config/Scripts/screen.sh deleted file mode 100755 index 03a8e79..0000000 --- a/.config/Scripts/screen.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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/.config/Scripts/screencast_alsa.sh b/.config/Scripts/screencast_alsa.sh deleted file mode 100755 index 95c1d5d..0000000 --- a/.config/Scripts/screencast_alsa.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/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/.config/Scripts/screencast_pulse.sh b/.config/Scripts/screencast_pulse.sh deleted file mode 100755 index 8491606..0000000 --- a/.config/Scripts/screencast_pulse.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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/.config/Scripts/shortcuts.sh b/.config/Scripts/shortcuts.sh deleted file mode 100755 index 0976e5f..0000000 --- a/.config/Scripts/shortcuts.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/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/.config/Scripts/spawndl b/.config/Scripts/spawndl deleted file mode 100755 index a419041..0000000 --- a/.config/Scripts/spawndl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -i3 exec "st -n dl -e youtube-dl $1" diff --git a/.config/Scripts/speedvid.sh b/.config/Scripts/speedvid.sh deleted file mode 100755 index ba3a4f6..0000000 --- a/.config/Scripts/speedvid.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -base=$(basename $1) -ext="${base##*.}" -base="${base%.*}" - -ffmpeg -i $1 -vf "setpts=$2*PTS" -an $base'_sped.'$ext diff --git a/.config/Scripts/tmuxinit b/.config/Scripts/tmuxinit deleted file mode 100755 index 68a4b86..0000000 --- a/.config/Scripts/tmuxinit +++ /dev/null @@ -1,4 +0,0 @@ -#!/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/.config/Scripts/transmission.sh b/.config/Scripts/transmission.sh deleted file mode 100755 index 794f6bb..0000000 --- a/.config/Scripts/transmission.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -if [ -f $(pgrep transmission) ]; - then - urxvt -e transmission-remote-cli - else - transmission-daemon && urxvt -e transmission-remote-cli -fi diff --git a/.config/Scripts/video.sh b/.config/Scripts/video.sh deleted file mode 100755 index ac3dc5c..0000000 --- a/.config/Scripts/video.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/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/.config/Scripts/webview b/.config/Scripts/webview deleted file mode 100755 index 17462fc..0000000 --- a/.config/Scripts/webview +++ /dev/null @@ -1,23 +0,0 @@ -#!/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/.config/Scripts/welcome b/.config/Scripts/welcome deleted file mode 100755 index 2e33713..0000000 --- a/.config/Scripts/welcome +++ /dev/null @@ -1,4 +0,0 @@ -#!/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 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 -- cgit v1.3.1