diff --git a/appvm-xpra b/appvm-xpra deleted file mode 100755 index 17be95f..0000000 --- a/appvm-xpra +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/python3 - -import argparse -import libvirt -import os -import shlex -import socket -import subprocess -import time -import yaml -from xml.etree import ElementTree - - -def domain_to_addr(name, uri='qemu:///system'): - v = libvirt.open('qemu:///system') - domain = v.lookupByName(name) - if domain.isActive() != 1: - raise Exception("VM is not running") - - ifaces = domain.interfaceAddresses(0) - for iface in ifaces.values(): - return iface['addrs'][0]['addr'] - - ifaces = domain.interfaceAddresses(1) - for iface, data in ifaces.items(): - if iface != 'lo': - for addr in data['addrs']: - if addr['type'] == 1 and addr['addr'][0:6] == 'fe80::': - continue - return addr['addr'] - - raise Exception("No interfaces found on VM") - - -def domain_to_cid(name, uri='qemu:///system'): - v = libvirt.openReadOnly('qemu:///system') - domain = v.lookupByName(name) - if domain.isActive() != 1: - raise Exception("VM is not running") - - et = ElementTree.fromstring(domain.XMLDesc()) - return et.find('devices/vsock/cid').attrib['address'] - - -def scp_if_exists(path, host, user=None, scp_args=['scp']): - local_path = os.path.expanduser(os.path.join('~', path)) - if os.path.exists(path): - if user is not None: - dest = '{0}@{1}:{2}'.format(user, host, path) - else: - dest = '{0}:{1}'.format(host, path) - - subprocess.call(scp_args + [local_path, dest]) - - -def xpra_attach(cid, xpra_title): - return subprocess.call([ - 'xpra', 'attach', - 'vsock://{0}:14500'.format(cid), - '--encoding=rgb', - '--title={0}'.format(xpra_title), - '--tray=no', - '--notifications=no', - '--username=user', - '--desktop-scaling=no', - ]) - - -if __name__ == '__main__': - default_user = "user" - default_identity = None - - try: - import xdg.BaseDirectory - configpath = xdg.BaseDirectory.load_first_config( - 'appvm/config.yml') - except ModuleNotFoundError: - configpath = os.path.expanduser('~/.config/appvm/config.yml') - - if os.path.exists(configpath): - config = yaml.safe_load(open(configpath)) - default_user = config.get('user', default_user) - default_identity = config.get('identity', default_identity) - - parser = argparse.ArgumentParser( - description="Connect to AppVMs using Xpra over SSH") - parser.add_argument('--cid', required=False, - help="vsock CID (required if not using libvirt)") - parser.add_argument('--user', '-u', '-l', default=default_user, - help="SSH username") - parser.add_argument('--identity', '-i', default=default_identity, - help="SSH identity file") - parser.add_argument('--shell', action='store_true', - help="Connect using SSH instead of Xpra") - parser.add_argument('--skip-libvirt', action='store_true', - help="Skip Libvirt (use domain name as SSH host)") - parser.add_argument('--disable-ssh-vsock', action='store_true', - help="Disable connections to SSH using AF_VSOCK") - parser.add_argument('domain_name', help="Libvirt domain name of VM") - parser.add_argument('app', nargs=argparse.REMAINDER, - help="App to launch") - args = parser.parse_args() - - system_hostname = socket.gethostname() - domain_name = args.domain_name - - if args.skip_libvirt: - xpra_host = domain_name - user = None - identity_file = None - else: - split_dname = domain_name.split('@', 1) - if len(split_dname) > 1: - user = split_dname[0] - domain_name = split_dname[1] - else: - user = args.user - - if not args.disable_ssh_vsock: - xpra_host = domain_name - else: - xpra_host = domain_to_addr(domain_name) - identity_file = args.identity - - if args.cid is not None: - cid = args.cid - else: - cid = domain_to_cid(domain_name) - - xpra_display = 10 - xpra_title = "@title@ on {0}".format(domain_name) - - ssh_args = ['ssh'] - scp_args = ['scp'] - if identity_file is not None: - ssh_args += ['-i', identity_file] - scp_args += ['-i', identity_file] - if user is not None: - ssh_args += ['-l', user] - if not args.skip_libvirt: - hka_arg = [ - '-o', - f'HostKeyAlias=appvm:{system_hostname}:{domain_name}' - ] - ssh_args += hka_arg - scp_args += hka_arg - if not args.disable_ssh_vsock: - pc_arg = [ - '-o', - f'ProxyCommand=socat vsock-connect:{cid}:22 -', - ] - ssh_args += pc_arg - scp_args += pc_arg - - if args.shell: - subprocess.call(ssh_args + [xpra_host] + args.app) - else: - ssh_cmd = ' '.join(ssh_args) - - if len(args.app) <= 0: - app = "firefox" - else: - app = args.app[0] - - p = xpra_attach(cid, xpra_title) - if p != 0: - scp_if_exists('.config/gtk-2.0/gtkrc', xpra_host, user, scp_args) - scp_if_exists('.config/gtk-3.0/settings.ini', xpra_host, user, - scp_args) - - subprocess.call(ssh_args + [xpra_host] + [ - 'xpra', 'start', ':{0}'.format(xpra_display), - '--bind-vsock=auto:14500', - '--start-after-connect={0}'.format(shlex.quote(app)), - ]) - time.sleep(5) - xpra_attach(cid, xpra_title) diff --git a/appvm-xpra-torbrowser b/appvm-xpra-torbrowser deleted file mode 100755 index 3d9019d..0000000 --- a/appvm-xpra-torbrowser +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -attach=0 -xpra_host="$1" -libvirt_uri=qemu:///system -domstate=$(virsh -c "$libvirt_uri" -r domstate "$xpra_host") -conn_str=vsock://$(virsh -c "$libvirt_uri" -r dumpxml "$xpra_host" | grep cid | sed -E "s/^.*address='([0-9]+)'.*/\1/"):14500 - -if [[ "$domstate" != "running" ]]; then - echo "AppVM is not running." - exit 1 -fi - -if [[ -n "$GDK_SCALE" ]]; then - scale_factor=$GDK_SCALE - # TODO: this value must be calculated: 96 * scale_factor - dpi="192" -elif [[ -n "$GDK_DPI_SCALE" ]]; then - # FIXME: do calculations for these; remove hardcoded factor from below - # or maybe use a global scale env variable? - scale_factor="1.5" - dpi="96" -else - #scale_factor=1 - dpi="96" -fi - -function xpra_attach { - xpra attach "${conn_str}" \ - --encoding=rgb \ - --title="@title@ on ${xpra_host}" \ - --tray=no \ - --notifications=no \ - --username=user \ - --desktop-scaling=${scale_factor} --dpi=${dpi} -} - -xpra_attach -if [[ $? != 0 ]]; then - set -e - ssh "${xpra_host}" \ - xpra start :10 \ - --bind-vsock=auto:14500 \ - --env=TOR_CONTROL_PORT=9151 \ - --env=TOR_SKIP_LAUNCH=1 \ - --start-after-connect='"vglrun /home/user/tor-browser_en-US/Browser/start-tor-browser"' - sleep 5 - xpra_attach -fi diff --git a/noptime.py b/noptime.py deleted file mode 100755 index 1fedab1..0000000 --- a/noptime.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python3 - -import os.path -import pyhugh -import subprocess -import yaml - -try: - import xdg.BaseDirectory - configpath = xdg.BaseDirectory.load_first_config('mmhome', 'config.yml') -except: - configpath = os.path.expanduser('~/.config/mmhome/config.yml') - -config = yaml.safe_load(open(configpath)) -h = pyhugh.PyHugh(config['hue_bridge'], config['hue_username']) - -h.create_schedule({ - 'name': "Off", - 'command': { - 'address': "/api/{0}/groups/0/action".format(h.username), - 'method': "PUT", - 'body': { - 'on': False, - }, - }, - 'time': "PT00:00:25", - 'autodelete': True, -}) - -subprocess.call(['/usr/bin/systemctl', 'poweroff']) diff --git a/notmuch-fetch b/notmuch-fetch deleted file mode 100755 index 766105c..0000000 --- a/notmuch-fetch +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -mbsync -c "$XDG_CONFIG_HOME/isync/mbsyncrc" main || exit 1 -notmuch new -#notify-send --icon=mail-send-receive "Mail Synchronized" diff --git a/openswan_to_pem.py b/openswan_to_pem.py deleted file mode 100755 index f3de947..0000000 --- a/openswan_to_pem.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python - -from Crypto.PublicKey import RSA - -comps = {} - -with open('/etc/ipsec.secrets') as f: - for line in f: - line = line.split(':', 1) - if len(line) == 2: - k = line[0].strip() - - v = line[1].strip() - if v.startswith('0s'): - v = int(v[2:], 64) - elif v.startswith('0x'): - v = int(v[2:], 16) - - comps[k] = v - -r = RSA.construct((comps['Modulus'], comps['PublicExponent'], - comps['PrivateExponent'])) -print(r.exportKey('PEM').decode('ascii')) diff --git a/tahoe-repair-all b/tahoe-repair-all deleted file mode 100755 index 3dd587b..0000000 --- a/tahoe-repair-all +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -################################################################################ -# tahoe-repair-all - Automatic Tahoe-LAFS file repair -# -# author: Kevin Reid -################################################################################ - -for item in $(tahoe list-aliases | cut -f 1 -d :); do - echo '*** '"$item" - tahoe deep-check --repair --add-lease $item: | perl -pe 's/^/\t/' - echo -done diff --git a/weechat_notify.py b/weechat_notify.py deleted file mode 100755 index 9445f8d..0000000 --- a/weechat_notify.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python2 -################################################################################ -# weechat_notify.py - client end of RabbitMQ AMQP weechat notifications -# designed for use with: -# http://www.weechat.org/scripts/source/amqp_notify.rb.html/ -# -# author: mutantmonkey -################################################################################ - -import os.path -import pika -import yaml -from gi.repository import Notify - - -Notify.init("weechat") - -config = yaml.safe_load(open(os.path.expanduser('~/.config/weechat/config.yml'))) -connection = pika.BlockingConnection(pika.connection.URLParameters( - config['rabbitmq']['uri'])) -channel = connection.channel() - -channel.exchange_declare(exchange=config['rabbitmq']['exchange'], type='fanout') -result = channel.queue_declare(exclusive=True) -queue_name = result.method.queue -channel.queue_bind(exchange=config['rabbitmq']['exchange'], queue=queue_name) - -def handle_notify(ch, method, properties, body): - body = body.replace('!binary', '!!binary') - data = yaml.safe_load(body) - n = Notify.Notification.new( - "{server}.{channel}".format(server=data[':server'], - channel=data[':channel']), - data[':message'], 'dialog-information') - n.show() - -channel.basic_consume(handle_notify, queue=queue_name, no_ack=True) -channel.start_consuming() diff --git a/whatsapp-web b/whatsapp-web deleted file mode 100755 index 5fe4835..0000000 --- a/whatsapp-web +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -if [[ -n "$GDK_SCALE" ]]; then - chromium \ - --proxy-server=socks5://127.0.0.1:9049 \ - --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE myproxy" \ - --user-data-dir=$HOME/.config/whatsapp \ - --profile-directory=Default \ - --force-device-scale-factor="$GDK_SCALE" \ - --app=https://web.whatsapp.com -else - chromium \ - --proxy-server=socks5://127.0.0.1:9049 \ - --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE myproxy" \ - --user-data-dir=$HOME/.config/whatsapp \ - --profile-directory=Default \ - -app=https://web.whatsapp.com -fi diff --git a/xvreset b/xvreset deleted file mode 100755 index 791291d..0000000 --- a/xvreset +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/zsh -{ xvattr -a XV_BRIGHTNESS -v 0 ; - xvattr -a XV_CONTRAST -v 0 ; - xvattr -a XV_SATURATION -v 0 ; - xvattr -a XV_HUE -v 0 ; } > /dev/null