From 164d1e8ec9fb9cec1c19be775e5abf6f173db62b Mon Sep 17 00:00:00 2001 From: James Bunton Date: Wed, 16 Jan 2019 17:42:30 +1100 Subject: [PATCH] Remove old stuff --- banshee-reset-sync | 5 -- clean-dkms | 42 ---------- photocopy | 6 -- pysendmail | 165 ---------------------------------------- scanimage-easy | 14 ---- set-font-xfce4-terminal | 79 ------------------- 6 files changed, 311 deletions(-) delete mode 100755 banshee-reset-sync delete mode 100755 clean-dkms delete mode 100755 photocopy delete mode 100755 pysendmail delete mode 100755 scanimage-easy delete mode 100755 set-font-xfce4-terminal diff --git a/banshee-reset-sync b/banshee-reset-sync deleted file mode 100755 index 8bbbdfc..0000000 --- a/banshee-reset-sync +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -e - -cd ~/.config/banshee-1 -sqlite3 banshee.db "UPDATE CoreTracks SET LastSyncedStamp = 0" - diff --git a/clean-dkms b/clean-dkms deleted file mode 100755 index e378a1c..0000000 --- a/clean-dkms +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -architecture="x86_64" -linux_packages="linux linux-lts" - -declare -A module2package -module2package[nvidia]="$(pacman -Qqs nvidia dkms)" -module2package[vboxhost]=virtualbox-host-dkms -module2package[broadcom-wl]=broadcom-wl-dkms -module2package[spl]=spl-dkms -module2package[zfs]=zfs-dkms - -echo "# Running: $(uname -r)" -for linux in $linux_packages; do - echo "# Installed: $(pacman -Q "$linux")" -done - -echo -find /var/lib/dkms/ -maxdepth 2 -type l -name 'kernel-*' | while read line; do - module_name="$(echo "$line" | cut -d/ -f5)" - package_name="${module2package[$module_name]}" - if [ -z "$package_name" ]; then - echo "Unknown module: $module_name" - exit 1 - fi - module_version="$(pacman -Q "${package_name}" | cut -d' ' -f2 | cut -d'-' -f1)" - long_kernel_version="$(echo "$line" | cut -d/ -f6)" - kernel_version="$(echo "$long_kernel_version" | sed -e 's/^kernel-//' -e "s/-${architecture}\$//")" - if [ "$kernel_version" = "$(uname -r)" ]; then - continue - fi - echo dkms remove -m "$module_name" -v "$module_version" -k "$kernel_version" -done - -echo -find /lib/modules/ -maxdepth 1 -type d -name '[0-9]*' | while read line; do - if pacman -Qo "$line" &> /dev/null; then - continue - fi - echo rm -rf "$line" -done - diff --git a/photocopy b/photocopy deleted file mode 100755 index 27408f0..0000000 --- a/photocopy +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -kdialog --yesno "Do you want to photocopy?" -if test $? = 0; then - scanimage | lpr -o scaling=100 - sh $0 & -fi diff --git a/pysendmail b/pysendmail deleted file mode 100755 index 593d786..0000000 --- a/pysendmail +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env python2 - -""" -sendmailish python program. -Usage: sendmail.py toaddress - - -Sample config file ------------------- -# vim:ft=python - -smtpServers = [ - SMTPProxy(remoteServer='mail.internode.on.net', domainSuffix='.internode.on.net'), - SMTPProxy(remoteServer='smtp.usyd.edu.au', domainSuffix='.usyd.edu.au'), - SMTPProxy(remoteServer='mail.iinet.net.au', domainSuffix='.iinet.net.au'), - SMTPProxy(remoteServer='mail.netspace.net.au', domainSuffix='.netspace.net.au'), - SMTPProxy(remoteServer='mail.optusnet.com.au', domainSuffix='.optusnet.com.au'), - SMTPProxySSH(remoteServer='delx.net.au', remoteSendmail='/usr/sbin/sendmail'), -] - -myIPURL = "http://suits.ug.it.usyd.edu.au/myip.php" -""" - - - -import smtplib, email, urllib -import os.path, subprocess, sys, optparse -import logging - -try: - # Attempt to load this debugging decorator function - from decorators import logCall -except ImportError: - def logCall(f): - '''This is a no-op decorator function''' - return f - - -class SMTPProxyBase(object): - def __repr__(self): - return '%s(%s)' % ( - self.__class__.__name__, - ', '.join('%s=%r' % (k, getattr(self, k)) for k in self.__slots__) - ) - -class SMTPProxy(SMTPProxyBase): - __slots__ = ( - 'remoteServer', - 'domainSuffix', - 'username', - 'password', - 'useSSL', - ) - @logCall - def __init__(self, remoteServer, domainSuffix, username=None, password=None, useSSL=False): - self.remoteServer = remoteServer - self.domainSuffix = domainSuffix - - self.username = username - self.password = password - self.useSSL = useSSL - - def doesHandle(self, localhostName): - '''Determines if this SMTPProxy can be used within this domain''' - if localhostName is None: - return False - else: - return localhostName.endswith(self.domainSuffix) - - def sendmail(self, fromAddr, toAddrs, message): - ''' - Actually send the mail. - - Returns true if the mail was successfully send - ''' - - smtp = smtplib.SMTP(self.remoteServer) - if self.useSSL: - smtp.starttls() - if self.username is not None and self.password is not None: - smtp.login(self.username, self.password) - smtp.sendmail(fromAddr, toAddrs, message) - smtp.quit() - return True - -class SMTPProxySSH(SMTPProxyBase): - __slots__ = ('remoteServer',) - @logCall - def __init__(self, remoteServer, remoteSendmail): - self.remoteServer = remoteServer - self.remoteSendmail = remoteSendmail - - def doesHandle(self, *args, **kwargs): - ''' - Determines if this SMTPProxySSH can be used within this domain. - Note: This method returns true for all values. - ''' - return True - - def sendmail(self, fromAddr, toAddrs, message): - ''' - Actually send the mail. - - Returns true if the mail was successfully send - ''' - cmdline = ['ssh', self.remoteServer, self.remoteSendmail, '--'] - cmdline.extend(toAddrs) - process = subprocess.Popen(cmdline, stdin=subprocess.PIPE) - process.communicate(message) - return not bool(process.wait()) - -def getOptionParser(): - parser = optparse.OptionParser(usage="%prog [options] toAddress1 [toAddress2] ...") - parser.add_option('--debug', - action='store_const', dest='debugLevel', const=logging.DEBUG, - help='Sets the logging level to debug') - parser.add_option('--warn', - action='store_const', dest='debugLevel', const=logging.WARNING, - help='Sets the logging level to warn') - parser.set_default('debugLevel', logging.ERROR) - - return parser - -def main(): - # Load the config file - try: - exec(open(os.path.expanduser('~/.sendmailpyrc'), 'r').read()) - except Exception, e: - print >>sys.stderr, 'Error with config file:', e - return False - - # Get the to addresses - parser = getOptionParser() - options, toAddrs = parser.parse_args() - logging.basicConfig(level=options.debugLevel) - if not toAddrs: - parser.error('No to addresses found') - - # Pick a SMTP server - try: - host = urllib.urlopen(myIPURL).read().strip() - except: - host = None - logging.exception('Failed to grab our external domain name') - - for smtpProxy in smtpServers: - if smtpProxy.doesHandle(host): - # Got the correct smtpServer - logging.info('Using the Proxy %r to connect from %s', smtpProxy, host) - break - else: - logging.error('Did not find a proxy to connect from %s', host) - return False - - # Get the from address - message = sys.stdin.read() - fromAddr = email.message_from_string(message)["from"] - _, fromAddr = email.utils.parseaddr(fromAddr) - - return smtpProxy.sendmail(fromAddr, toAddrs, message) - -if __name__ == "__main__": - # Specify SMTP servers here - sys.exit(not main()) - diff --git a/scanimage-easy b/scanimage-easy deleted file mode 100755 index cb16ff6..0000000 --- a/scanimage-easy +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -NUM="$(expr 1 + "$(cat current)")" -echo "${NUM}" > current -OUT="$(printf "scan_%04d.jpg" "${NUM}")" - -scanimage --progress --mode color --resolution 300dpi --gamma-value 0.999451 > out.pnm -echo "Scanning done..." - -tojpeg.py out.pnm "${OUT}" && -rm -f out.pnm -open "${OUT}" -echo "Written ${OUT}" - diff --git a/set-font-xfce4-terminal b/set-font-xfce4-terminal deleted file mode 100755 index ba4b19c..0000000 --- a/set-font-xfce4-terminal +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 - -import configparser -import math -import os -import sys - -def main(): - action = parse_action() - - if action == "+": - update_font_size(get_size_increment) - elif action == "-": - update_font_size(get_size_decrement) - else: - update_font_size(lambda _: action) - -def parse_action(): - if len(sys.argv) != 2: - print_help_exit() - - action = sys.argv[1] - if action != "+" and action != "-" and not action.isdigit(): - print_help_exit() - - if action.isdigit(): - action = int(action) - if action < 1: - print_help_exit() - - return action - -def print_help_exit(): - print("Usage: %s [+|-|22]", file=sys.stderr) - sys.exit(1) - -def get_size_increment(size): - if size >= 40: - return math.floor(size / 8) * 8 + 8 - if size >= 28: - return math.floor(size / 4) * 4 + 4 - if size >= 18: - return math.floor(size / 2) * 2 + 2 - return size + 1 - -def get_size_decrement(size): - if size > 40: - return math.ceil(size / 8) * 8 - 8 - if size > 28: - return math.ceil(size / 4) * 4 - 4 - if size > 18: - return math.ceil(size / 2) * 2 - 2 - return size - 1 - -def update_font_size(fn): - filename = get_config_filename() - config = configparser.RawConfigParser() - config.optionxform = lambda key: key - config.read(filename) - - font_name, old_size = config["Configuration"]["FontName"].rsplit(" ", 1) - new_size = fn(int(old_size)) - config["Configuration"]["FontName"] = "%s %s" % (font_name, new_size) - - print("Updating font size:", old_size, "->", new_size) - - with open(filename+".new", "w") as f: - config.write(f) - os.rename(filename+".new", filename) - -def get_config_filename(): - xdg_config_dir = os.environ.get("XDG_CONFIG_HOME", None) - if not xdg_config_dir: - xdg_config_dir = os.path.expanduser("~/.config") - return os.path.join(xdg_config_dir, "xfce4", "terminal", "terminalrc") - - -if __name__ == "__main__": - main() -- 2.39.2