From eb6d0bd888dfdd4ce9845148fceec80883b17bcc Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 18 Jul 2018 19:05:19 -0400 Subject: old scripts removed --- .scripts/offlineimap-daemon.py | 93 --------------------- .scripts/offlineimap-daemonctl.sh | 40 ---------- .scripts/screen.sh | 24 ------ .scripts/spawndl | 2 - .scripts/tpb | 164 ++++++++++++++++++++++++++++++++++++++ .scripts/tpb.sh | 164 -------------------------------------- .scripts/transmission.sh | 7 -- .scripts/welcome | 4 - 8 files changed, 164 insertions(+), 334 deletions(-) delete mode 100755 .scripts/offlineimap-daemon.py delete mode 100755 .scripts/offlineimap-daemonctl.sh delete mode 100755 .scripts/screen.sh delete mode 100755 .scripts/spawndl create mode 100755 .scripts/tpb delete mode 100755 .scripts/tpb.sh delete mode 100755 .scripts/transmission.sh delete mode 100755 .scripts/welcome (limited to '.scripts') diff --git a/.scripts/offlineimap-daemon.py b/.scripts/offlineimap-daemon.py deleted file mode 100755 index fea76fc..0000000 --- a/.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/.scripts/offlineimap-daemonctl.sh b/.scripts/offlineimap-daemonctl.sh deleted file mode 100755 index 18daf3d..0000000 --- a/.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/.scripts/screen.sh b/.scripts/screen.sh deleted file mode 100755 index 03a8e79..0000000 --- a/.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/.scripts/spawndl b/.scripts/spawndl deleted file mode 100755 index a419041..0000000 --- a/.scripts/spawndl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -i3 exec "st -n dl -e youtube-dl $1" diff --git a/.scripts/tpb b/.scripts/tpb new file mode 100755 index 0000000..fb1b5b6 --- /dev/null +++ b/.scripts/tpb @@ -0,0 +1,164 @@ +#!/bin/sh +# +# by Sairon Istyar, 2012 +# distributed under the GPLv3 license +# http://www.opensource.org/licenses/gpl-3.0.html +# + +### CONFIGURATION ### +# program to use for torrent download +# magnet link to torrent will be appended +# you can add -- at the end to indicate end of options +# (if your program supports it, most do) +program='/usr/bin/transmission-remote -a' +TPB="https://thepiratebay.org" + +# show N first matches by default +limit=50 + +# colors +numbcolor='\x1b[1;35m' +namecolor='\x1b[1;33m' +sizecolor='\x1b[1;36m' +seedcolor='\x1b[1;31m' +peercolor='\x1b[1;32m' +errocolor='\x1b[1;31m' +mesgcolor='\x1b[1;37m' +nonecolor='\x1b[0m' + +# default ordering method +# 1 - name ascending; 2 - name descending; +# 3 - recent first; 4 - oldest first; +# 5 - size descending; 6 - size ascending; +# 7 - seeds descending; 8 - seeds ascending; +# 9 - leechers descending; 10 - leechers ascending; +orderby=7 +### END CONFIGURATION ### + +thisfile="$0" + +printhelp() { + echo -e "Usage:" + echo -e "\t$thisfile [options] search query" + echo + echo + echo -e "Available options:" + echo -e "\t-h\t\tShow help" + echo -e "\t-n [num]\tShow only first N results (default 15; max 100 [top] or 30 [search])" + echo -e "\t-C\t\tDo not use colors" + echo -e "\t-P [prog]\tSet torrent client command (\`-P torrent-client\` OR \`-P \"torrent-client --options\"\`)" + echo + echo -e "Current client settings: $program [magnet link]" +} + +# change torrent client +chex() { + sed "s!^program=.*!program=\'$program\'!" -i "$thisfile" + if [ $? -eq 0 ] ; then + echo "Client changed successfully." + exit 0 + else + echo -e "${errocolor}(EE) ${mesgcolor}==> Something went wrong!${nonecolor}" + exit 1 + fi +} + +# script cmdline option handling +while getopts :hn:CP:: opt ; do + case "$opt" in + h) printhelp; exit 0;; + n) limit="$OPTARG";; + C) unset numbcolor namecolor sizecolor seedcolor peercolor nonecolor errocolor mesgcolor;; + P) program="$OPTARG"; chex;; + *) echo -e "Unknown option(s)."; printhelp; exit 1;; + esac +done + +shift `expr $OPTIND - 1` + +# correctly encode query +q=`echo "$*" | tr -d '\n' | od -t x1 -A n | tr ' ' '%'` + +# if not searching, show top torrents +if [ -z "$q" ] ; then + url="top/all" +else + url='search/'"$q"'/0/'"$orderby"'/0' +fi + +# get results +# Here be dragons! +r=`curl -k -A Mozilla -b "lw=s" -m 15 -s "$TPB/$url" \ + | grep -Eo '^]*>.*|^[^<]*' \ + | sed 's!^]*>!!; \ + s!$!!; \ + s!^]*>!!; \ + s! !\ !g; \ + s/|/!/g' \ + | sed 'N;N;N;N;s!\n!|!g'` + +# number of results +n=`echo "$r" | wc -l` + +IFS=$'\n' + +# print results +echo "$r" \ + | head -n "$limit" \ + | awk -v N=1 \ + -v NU="$numbcolor" \ + -v NA="$namecolor" \ + -v SI="$sizecolor" \ + -v SE="$seedcolor" \ + -v PE="$peercolor" \ + -v NO="$nonecolor" \ + -F '|' \ + '{print NU N ") " NA $1 " " SI $3 " " SE $4 " " PE $5 NO; N++}' + +# read ID(s), expand ranges, ignore everything else +read -p ">> Torrents to download (eg. 1 3 5-7): " selection +IFS=$'\n\ ' +for num in $selection ; do + if [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*'`" ] ; then + down="$down $num" + elif [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*-[[:digit:]][[:digit:]]*'`" ] ; then + seqstart="${num%-*}" + seqend="${num#*-}" + if [ $seqstart -le $seqend ] ; then + down="$down `seq $seqstart $seqend`" + fi + fi +done + +# normalize download list, sort it and remove dupes +down="$(echo $down | tr '\ ' '\n' | sort -n | uniq)" +IFS=$'\n' + +# check whether we're downloading something, else exit +if [ -z "$down" ] ; then + exit 0 +fi + +# download all torrents in list +echo -n "Downloading torrent(s): " +for torrent in $down ; do + # check if ID is valid and in range of results, download torrent + if [ $torrent -ge 1 ] ; then + if [ $torrent -le $limit ] ; then + echo -n "$torrent " + command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`" + status=$(eval "$command" 2>&1) + if [ $? -ne 0 ] ; then + echo -n '(failed!) ' + report="$report\n(#$torrent) $status" + fi + fi + fi +done +echo +if [ -n "$report" ] ; then + echo -n "Exited with errors:" + echo -e "$report" +fi +unset IFS diff --git a/.scripts/tpb.sh b/.scripts/tpb.sh deleted file mode 100755 index fb1b5b6..0000000 --- a/.scripts/tpb.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/sh -# -# by Sairon Istyar, 2012 -# distributed under the GPLv3 license -# http://www.opensource.org/licenses/gpl-3.0.html -# - -### CONFIGURATION ### -# program to use for torrent download -# magnet link to torrent will be appended -# you can add -- at the end to indicate end of options -# (if your program supports it, most do) -program='/usr/bin/transmission-remote -a' -TPB="https://thepiratebay.org" - -# show N first matches by default -limit=50 - -# colors -numbcolor='\x1b[1;35m' -namecolor='\x1b[1;33m' -sizecolor='\x1b[1;36m' -seedcolor='\x1b[1;31m' -peercolor='\x1b[1;32m' -errocolor='\x1b[1;31m' -mesgcolor='\x1b[1;37m' -nonecolor='\x1b[0m' - -# default ordering method -# 1 - name ascending; 2 - name descending; -# 3 - recent first; 4 - oldest first; -# 5 - size descending; 6 - size ascending; -# 7 - seeds descending; 8 - seeds ascending; -# 9 - leechers descending; 10 - leechers ascending; -orderby=7 -### END CONFIGURATION ### - -thisfile="$0" - -printhelp() { - echo -e "Usage:" - echo -e "\t$thisfile [options] search query" - echo - echo - echo -e "Available options:" - echo -e "\t-h\t\tShow help" - echo -e "\t-n [num]\tShow only first N results (default 15; max 100 [top] or 30 [search])" - echo -e "\t-C\t\tDo not use colors" - echo -e "\t-P [prog]\tSet torrent client command (\`-P torrent-client\` OR \`-P \"torrent-client --options\"\`)" - echo - echo -e "Current client settings: $program [magnet link]" -} - -# change torrent client -chex() { - sed "s!^program=.*!program=\'$program\'!" -i "$thisfile" - if [ $? -eq 0 ] ; then - echo "Client changed successfully." - exit 0 - else - echo -e "${errocolor}(EE) ${mesgcolor}==> Something went wrong!${nonecolor}" - exit 1 - fi -} - -# script cmdline option handling -while getopts :hn:CP:: opt ; do - case "$opt" in - h) printhelp; exit 0;; - n) limit="$OPTARG";; - C) unset numbcolor namecolor sizecolor seedcolor peercolor nonecolor errocolor mesgcolor;; - P) program="$OPTARG"; chex;; - *) echo -e "Unknown option(s)."; printhelp; exit 1;; - esac -done - -shift `expr $OPTIND - 1` - -# correctly encode query -q=`echo "$*" | tr -d '\n' | od -t x1 -A n | tr ' ' '%'` - -# if not searching, show top torrents -if [ -z "$q" ] ; then - url="top/all" -else - url='search/'"$q"'/0/'"$orderby"'/0' -fi - -# get results -# Here be dragons! -r=`curl -k -A Mozilla -b "lw=s" -m 15 -s "$TPB/$url" \ - | grep -Eo '^]*>.*|^[^<]*' \ - | sed 's!^]*>!!; \ - s!$!!; \ - s!^]*>!!; \ - s! !\ !g; \ - s/|/!/g' \ - | sed 'N;N;N;N;s!\n!|!g'` - -# number of results -n=`echo "$r" | wc -l` - -IFS=$'\n' - -# print results -echo "$r" \ - | head -n "$limit" \ - | awk -v N=1 \ - -v NU="$numbcolor" \ - -v NA="$namecolor" \ - -v SI="$sizecolor" \ - -v SE="$seedcolor" \ - -v PE="$peercolor" \ - -v NO="$nonecolor" \ - -F '|' \ - '{print NU N ") " NA $1 " " SI $3 " " SE $4 " " PE $5 NO; N++}' - -# read ID(s), expand ranges, ignore everything else -read -p ">> Torrents to download (eg. 1 3 5-7): " selection -IFS=$'\n\ ' -for num in $selection ; do - if [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*'`" ] ; then - down="$down $num" - elif [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*-[[:digit:]][[:digit:]]*'`" ] ; then - seqstart="${num%-*}" - seqend="${num#*-}" - if [ $seqstart -le $seqend ] ; then - down="$down `seq $seqstart $seqend`" - fi - fi -done - -# normalize download list, sort it and remove dupes -down="$(echo $down | tr '\ ' '\n' | sort -n | uniq)" -IFS=$'\n' - -# check whether we're downloading something, else exit -if [ -z "$down" ] ; then - exit 0 -fi - -# download all torrents in list -echo -n "Downloading torrent(s): " -for torrent in $down ; do - # check if ID is valid and in range of results, download torrent - if [ $torrent -ge 1 ] ; then - if [ $torrent -le $limit ] ; then - echo -n "$torrent " - command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`" - status=$(eval "$command" 2>&1) - if [ $? -ne 0 ] ; then - echo -n '(failed!) ' - report="$report\n(#$torrent) $status" - fi - fi - fi -done -echo -if [ -n "$report" ] ; then - echo -n "Exited with errors:" - echo -e "$report" -fi -unset IFS diff --git a/.scripts/transmission.sh b/.scripts/transmission.sh deleted file mode 100755 index 794f6bb..0000000 --- a/.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/.scripts/welcome b/.scripts/welcome deleted file mode 100755 index 2e33713..0000000 --- a/.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 -- cgit v1.3.1