diff options
-rw-r--r-- | README.md | 6 | ||||
-rwxr-xr-x | anarchronofile | 99 | ||||
-rwxr-xr-x | android-backup | 159 | ||||
l--------- | android-pull | 1 | ||||
-rwxr-xr-x | android-push | 35 | ||||
l--------- | android-restore | 1 | ||||
-rwxr-xr-x | build | 46 | ||||
-rwxr-xr-x | catcode | 30 | ||||
-rwxr-xr-x | chownme | 18 | ||||
-rwxr-xr-x | collector | 45 | ||||
-rwxr-xr-x | copy-annotations-from-kobo | 67 | ||||
-rwxr-xr-x | copy-item-to-kobo | 54 | ||||
-rwxr-xr-x | dangling-archive | 48 | ||||
-rwxr-xr-x | dict | 20 | ||||
-rwxr-xr-x | doi2bib | 53 | ||||
-rwxr-xr-x | dupbackup | 51 | ||||
-rwxr-xr-x | export-firefox-bookmarks | 40 | ||||
-rwxr-xr-x | export-koreader-note | 46 | ||||
-rwxr-xr-x | export-pad | 18 | ||||
-rwxr-xr-x | fixmes | 18 | ||||
-rwxr-xr-x | gallery | 22 | ||||
-rwxr-xr-x | icalbuddy | 8 | ||||
-rwxr-xr-x | keyringer-export-pads | 35 | ||||
l--------- | luakit-adblock-update | 1 | ||||
-rwxr-xr-x | mvln | 23 | ||||
-rwxr-xr-x | openvpn-resolv-conf | 47 | ||||
-rwxr-xr-x | powersaving | 35 | ||||
-rwxr-xr-x | pw | 6 | ||||
-rwxr-xr-x | reminders | 8 | ||||
-rwxr-xr-x | screenshot | 13 | ||||
-rwxr-xr-x | scuttle | 79 | ||||
-rwxr-xr-x | show | 119 | ||||
-rwxr-xr-x | sri-hash | 34 | ||||
-rwxr-xr-x | status | 146 | ||||
-rwxr-xr-x | suser | 15 | ||||
-rwxr-xr-x | sync-from-kobo | 34 | ||||
-rwxr-xr-x | sync-to-kobo | 28 | ||||
-rwxr-xr-x | task | 14 | ||||
-rwxr-xr-x | tasks | 57 | ||||
-rwxr-xr-x | telneter | 22 | ||||
-rwxr-xr-x | timew-shell | 32 | ||||
-rwxr-xr-x | todo | 120 | ||||
-rwxr-xr-x | tomb-close | 34 | ||||
-rwxr-xr-x | tomb-create | 47 | ||||
-rwxr-xr-x | tomb-open | 34 | ||||
-rwxr-xr-x | urlinfo | 43 | ||||
l--------- | urlmd | 1 | ||||
-rwxr-xr-x | urlsave | 21 | ||||
-rwxr-xr-x | urlssave | 10 | ||||
-rwxr-xr-x | vnc | 80 | ||||
-rwxr-xr-x | weather-forecast | 36 | ||||
-rwxr-xr-x | weather-query | 40 | ||||
-rwxr-xr-x | wifi | 16 | ||||
-rwxr-xr-x | xclip-ssh | 106 | ||||
-rwxr-xr-x | xdg-add | 16 | ||||
-rwxr-xr-x | youtube-player | 18 |
56 files changed, 3 insertions, 2252 deletions
@@ -1,4 +1,4 @@ -Misc scripts -============ +# Misc scripts -This is a collection of simple scripts to be available on $PATH. +This repository is used as an assorted collection of simple scripts to be +available on `$PATH`. diff --git a/anarchronofile b/anarchronofile deleted file mode 100755 index 26ee7e5..0000000 --- a/anarchronofile +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Ana(r)chronofile parser. -# -# Copyright (C) 2021 Silvio Rhatto <rhatto@riseup.net> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, -# or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# Dependencies -import os -import yaml -import argparse -from pprint import pprint - -class AnarChronofile: - def __init__(self, args): - if not os.path.exists(args.file[0]): - raise FileNotFoundError('File not found: ' + args.file[0]) - - if os.path.isfile(args.file[0]): - self.args = args - self.file = open(args.file[0], '+r') - self.yaml = yaml.load(self.file) - - def run(self): - if getattr(self, 'args', None) is None: - return - - print(self.args) - print("---") - print("") - - if self.args.topic is not None: - topic = self.args.topic - - for item in self.yaml: - if topic in item: - if self.args.subtopic is not None: - subtopic = self.args.subtopic - - if subtopic in item[topic]: - print('Date: ' + str(item['date'])) - print("\n") - pprint(item[topic][subtopic]) - print("\n") - - else: - print('Date: ' + str(item['date'])) - print("\n") - pprint(item[topic]) - print("\n") - - else: - pprint(self.yaml) - -def cmdline(): - """ - Evalutate the command line. - - :return: Command line arguments. - """ - - basename = os.path.basename(__file__) - examples = "Examples:\n\t" + basename + " incoming.yaml\n" - epilog = examples - parser = argparse.ArgumentParser(description='Parse an ana(r)chronofile', - epilog=epilog, - formatter_class=argparse.RawDescriptionHelpFormatter,) - - parser.add_argument('file', nargs=1, help='YAML file') - parser.add_argument('topic', nargs='?', help='Topic to search') - parser.add_argument('subtopic', nargs='?', help='Subtopic to search') - - # Get args - args = parser.parse_args() - - return args - -if __name__ == "__main__": - args = cmdline() - - try: - parser = AnarChronofile(args) - parser.run() - except (FileNotFoundError, KeyboardInterrupt) as e: - print(e) - exit(1) diff --git a/android-backup b/android-backup deleted file mode 100755 index 1985f6b..0000000 --- a/android-backup +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# -# Android backup -# - -# Basic parameters -BASENAME="`basename $0`" -NAME="$1" - -# Backup user files -function android_backup_files { - if [ ! -z "$1" ]; then - USER_ID="$1" - else - USER_ID="0" - fi - - BASE="/storage" - EMULATED="$BASE/emulated/$USER_ID" - - # Files: full copy - #adb pull $EMULATED files/ - - # Remove multimedia cache from backup - #rm -rf files/Music - - # Files: full basic copy - #adb shell ls -1 $EMULATED | grep -v ^Music | while read file; do - # adb pull $EMULATED/$file files/ - #done - - mkdir -p files/$USER_ID - - # Files: incremental basic copy - for file in `adb shell ls -1 $EMULATED | grep -v '^Music'`; do - adb-sync --delete --reverse $EMULATED/$file files/$USER_ID/ - done - - # SD cards - for file in `adb shell ls -1 $BASE | grep -v "^self" | grep -v "^emulated"`; do - adb-sync --delete --reverse $BASE/$file files/ - done -} - -# Restore user files -function android_restore_files { - if [ ! -z "$1" ]; then - USER_ID="$1" - else - USER_ID="0" - fi - - BASE="/storage/emulated/$USER_ID" - - # Files: complete copy - #for file in `ls files`; do - # adb push files/$file $base/$file - #done - - # Files: incremental copy - for file in `ls $WORK/android-backup-$NAME-$DATE/files/$USER_ID`; do - adb-sync --delete $WORK/android-backup-$NAME-$DATE/files/$USER_ID/$file/ $BASE/$file/ - done -} - -function android_backup_backup { - # Check previous backup - if [ -d "$STORAGE/$DATE" ]; then - echo "backup for $DATE already exists" - exit 1 - fi - - # Work folder - mkdir -p $WORK/android-backup-$NAME-$DATE && cd $WORK/android-backup-$NAME-$DATE &> /dev/null || exit 1 - - # If you have a previous backup you might want to use it with hardlinks - if [ -e "$STORAGE/$PREVIOUS/files" ]; then - sudo cp -alf $STORAGE/$PREVIOUS/files files - fi - - # Ensure we have a files folder - mkdir -p files - - # Contacts. Export also to a .vcf directly from the contact app - adb-export.sh -e content://com.android.contacts/contacts - adb shell content query --uri content://com.android.contacts/contacts > contacts.rows - - # User and system information - adb shell dumpsys user > users.dump - adb shell dumpsys > system.dump - - # Configurations - # Right now this is possible only for the main user - # https://stackoverflow.com/questions/50978678/adb-backup-restore-multiple-users-apps - # https://android.stackexchange.com/questions/43043/non-root-backup-with-multiple-users-non-owner-or-secondary-users - #adb backup -apk -shared -all - adb backup -all - - # Backup each user files - for USER in $USERS; do - android_backup_files $USER - done - - # Move backup to storage - cd .. &> /dev/null && sudo mv android-backup-$NAME-$DATE $STORAGE/$DATE -} - -function android_backup_restore { - # Check for previous backups - if [ -z "$PREVIOUS" ]; then - echo "$BASENAME: no previous backups for device $NAME" - exit 1 - fi - - # Copy files to workfolder - mkdir -p $WORK && sudo cp -alf $STORAGE/$PREVIOUS $WORK/android-backup-$NAME-$DATE && chown -R `whoami`. android-backup-$NAME-$DATE - - # Check if copy was successful - if [ ! -e "$WORK/android-backup-$NAME-$DATE" ]; then - echo "$BASENAME: could not copy from $STORAGE/$PREVIOUS" - exit 1 - fi - - # Restore each user files - if [ -e "$WORK/android-backup-$NAME-$DATE" ]; then - for USER in $USERS; do - android_restore_files $USER - done - fi - - # Configurations - adb restore android-backup-$NAME-$DATE/backup.ab - - # Cleanup - rm -rf android-backup-$NAME-$DATE -} - -# Syntax check -if [ -z "$NAME" ]; then - echo "$BASENAME: missing phone name" - exit 1 -fi - -# Additional parameters -WORK="/var/data/load" -DATE="`date +%Y%m%d`" -STORAGE="/var/backups/remote/$NAME.`facter domain`/" -USERS="`adb shell pm list users | grep '{' | cut -d '{' -f 2 | cut -d ':' -f 1 | xargs`" - -# Dest folder and previous backups -sudo mkdir -p $STORAGE -PREVIOUS="`sudo ls -1 $STORAGE | tac | head -n 1`" - -# Dispatch -if [ "$BASENAME" == "android-backup" ]; then - android_backup_backup -else - android_backup_restore -fi diff --git a/android-pull b/android-pull deleted file mode 120000 index 4bac549..0000000 --- a/android-pull +++ /dev/null @@ -1 +0,0 @@ -android-push
\ No newline at end of file diff --git a/android-push b/android-push deleted file mode 100755 index 1eafa10..0000000 --- a/android-push +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# Push and pull to android device. -# - -# Parameters -BASENAME="`basename $0`" -ORIG="$1" -DEST="$2" -ANDROID_BASE="${3:-/storage/emulated/0}" - -# Check -if [ -z "$DEST" ]; then - echo "Usage: $BASENAME <orig> <dest> [android-base]" - echo "" - echo "Examples" - echo "" - echo "android-push /mylocal/music/ Music/" - echo "androis-pull DCIM/Camera /mylocal/camera" - echo "androis-pull Music /mylocal/music" - echo "androis-pull Ringtones /mylocal/ringtones $ANDROID_BASE" - exit 1 -fi - -# Run -if [ "$BASENAME" == "android-pull" ]; then - adb pull $ANDROID_BASE/$ORIG $DEST -else - adb push $ORIG $ANDROID_BASE/$DEST - - # Thanks https://stackoverflow.com/questions/17928576/refresh-android-mediastore-using-adb - #adb shell "find $ANDROID_BASE/$DEST -exec am broadcast \ - #-a android.intent.action.MEDIA_SCANNER_SCAN_FILE \ - #-d file://{} \\;" -fi diff --git a/android-restore b/android-restore deleted file mode 120000 index 6ccc9f5..0000000 --- a/android-restore +++ /dev/null @@ -1 +0,0 @@ -android-backup
\ No newline at end of file @@ -1,46 +0,0 @@ -#!/bin/bash -# -# build is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or any later version. -# -# build is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 59 Temple -# Place - Suite 330, Boston, MA 02111-1307, USA -# - -BASENAME="`basename $0`" - -#LIBDIR="/usr/lib" -#if [ "$ARCH" = "x86_64" ]; then -# FPIC="export CFLAGS=-fPIC" -# LDFLAGS='export LDFLAGS="-L/lib64 -L/usr/lib64"' -# LIBDIR="/usr/lib64" -#fi - -#CONF="./configure --prefix=/usr --sysconfdir=/etc --libdir=$LIBDIR" -CONF="./configure --prefix=/usr --sysconfdir=/etc" -INSTALL="make DESTDIR=`pwd`/installation/ install" -HELP="./configure --help | less" -MAKE="make" - -case $1 in - "--conf") $CONF ;; - "--fpic") $FPIC ;; - "--ld") $LDFLAGS ;; - "--make") $MAKE ;; - "--install") $INSTALL ;; - "--help") $HELP ;; - "--show") - echo $FPIC - echo $LDFLAGS - echo $CONF - echo $INSTALL - ;; - *) $CONF ; $MAKE ;; -esac - diff --git a/catcode b/catcode deleted file mode 100755 index fb3b99d..0000000 --- a/catcode +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# -# Display the source of a script. -# - -# Parameters -BASENAME="`basename $0`" -COMMAND="$1" -PAGER="$2" - -# Check -if [ -z "$COMMAND" ]; then - echo "usage: $BASENAME <command>" -elif [ ! -e "$COMMAND" ]; then - COMMAND="`which $COMMAND 2> /dev/null`" - - if [ -z "$COMMAND" ]; then - echo "$BASENAME: cannot find command" - exit 1 - fi -fi - -# Shebang checker -if head -1 $COMMAND | grep -q '#!'; then - if [ -z "$PAGER" ]; then - cat $COMMAND - elif [ "$PAGER" == "less" ]; then - less $COMMAND - fi -fi diff --git a/chownme b/chownme deleted file mode 100755 index 4a37e90..0000000 --- a/chownme +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# Chown a destination to the current user. -# - -# Parameters -BASENAME="`basename $0`" -DEST="$*" -ME="$(whoami)" - -# Check -if [ -z "$1" ]; then - echo "usage: $BASENAME <dest>" - exit 1 -fi - -# Proceed -sudo chown -R $ME. "$DEST" diff --git a/collector b/collector deleted file mode 100755 index 5967e52..0000000 --- a/collector +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -# -# Collector: add, view, edit a collector file (from GTD/ZTD methodologies). -# -# The collector file is a Markdown file with the Task list extension, such as -# https://docs.gitlab.com/ee/user/markdown.html#task-lists -# - -# Parameters -BASENAME="`basename $0`" -ACTION="$1" - -# Check -if [ -z "$COLLECTOR_FILE" ]; then - # Do not be verbose here, otherwise the "status" command will show an error - # message on unconfgirued systems. Maybe that should be controlled by a verbosity flag. - #echo "$BASENAME: please export the COLLECTOR_FILE environment variable pointing to your collector markdown file" - - exit 1 -elif [ ! -e "$COLLECTOR_FILE" ]; then - echo "$BASENAME: error: file not found: $COLLECTOR_FILE" - exit 1 -fi - -# Dispatch -if [ -z "$ACTION" ] || [ "$ACTION" == "view" ]; then - cat "$COLLECTOR_FILE" -elif [ "$ACTION" == "add" ]; then - shift - echo "* $*" >> "$COLLECTOR_FILE" -elif [ "$ACTION" == "list" ]; then - if grep -q -e "^ *\* " "$COLLECTOR_FILE"; then - echo "Collected items at $COLLECTOR_FILE:" - echo "" - grep -e "^ *\* " "$COLLECTOR_FILE" - echo "" - fi -elif [ "$ACTION" == "edit" ]; then - if [ ! -z "$EDITOR" ]; then - $EDITOR "$COLLECTOR_FILE" - else - echo "$BASENAME: error: please export the EDITOR environment variable pointing to your editor of choice" - exit 1 - fi -fi diff --git a/copy-annotations-from-kobo b/copy-annotations-from-kobo deleted file mode 100755 index f86d1fe..0000000 --- a/copy-annotations-from-kobo +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# A mini-wrapper to copy a remote kobo annotation into a local one. -# - -# Parameters -BASENAME="`basename $0`" -BASEFOLDER="$HOME/data/doc" -REMOTE_BASE="/mnt/sd" -REMOTE="kobo" -PATTERN="$1" - -# Thanks https://serverfault.com/a/764403 -# https://serverfault.com/questions/36421/stop-ssh-login-from-printing-motd-from-the-client#38160 -function silentSsh { - local connectionString="$1" - shift - local commands="$*" - if [ -z "$commands" ]; then - commands=`cat` - fi - ssh -T $connectionString "$commands" -} - -# Check -if [ -z "$PATTERN" ]; then - echo "usage: $BASENAME <pattern>" - exit 1 -fi - -# Dispatch -show --search "$PATTERN" | while read item; do - #sdr="`echo $item | sed -e 's/\.pdf$//' -e 's/\.epub$//' -e 's/\.djvuf$//'`.sdr" - basename="`echo $item | sed -e 's/\.[^.]*$//'`" - extension="$(echo $item | sed -e "s|$basename.||")" - sdr="$basename.sdr" - - # Check if remote file exists - silentSsh $REMOTE <<EOT - test -e "$REMOTE_BASE/$sdr/metadata.$extension.lua" -EOT - - # Skip if remote file does not exist - if [ "$?" != "0" ]; then - echo "Skipping $item as it's not available at $REMOTE..." - continue - fi - - echo "Processing $item..." - - # Make sure that the annotation file exists - mkdir -p "$BASEFOLDER/$sdr" - touch "$BASEFOLDER/$sdr/metadata.$extension.lua" - - # Make sure it's not locked by git annex - if [ -L "$BASEFOLDER/$sdr/metadata.$extension.lua" ]; then - git -C $BASEFOLDER annex unlock "$sdr/metadata.$extension.lua" - fi - - # Update - silentSsh kobo >"$BASEFOLDER/$sdr/metadata.$extension.lua" <<EOF - cat "$REMOTE_BASE/$sdr/metadata.$extension.lua" -EOF - - # Stage - git -C $BASEFOLDER add "$sdr/metadata.$extension.lua" -done diff --git a/copy-item-to-kobo b/copy-item-to-kobo deleted file mode 100755 index aa751fb..0000000 --- a/copy-item-to-kobo +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# A mini-wrapper to copy a local item to kobo. -# - -# Parameters -BASENAME="`basename $0`" -BASEFOLDER="$HOME/data/doc" -REMOTE_BASE="/mnt/sd" -REMOTE="kobo" -PATTERN="$1" -TMPFILE="tmpwork" - -# Thanks https://serverfault.com/a/764403 -# https://serverfault.com/questions/36421/stop-ssh-login-from-printing-motd-from-the-client#38160 -function silentSsh { - local connectionString="$1" - shift - local commands="$*" - if [ -z "$commands" ]; then - commands=`cat` - fi - ssh -T $connectionString "$commands" -} - -# Check -if [ -z "$PATTERN" ]; then - echo "usage: $BASENAME <pattern>" - exit 1 -fi - -# Dispatch -show --search "$PATTERN" | while read item; do - dirname="`dirname "$item"`" - - # Check if item has unspported chars in it's file name - if echo "$item" | grep -q ':'; then - echo "$BASENAME: unsupported character ':' in file name '$item'" - echo "$BASENAME: please rename the file and try again" - exit 1 - fi - - echo "Copying $item..." - - silentSsh $REMOTE <<EOC - mkdir -p "$REMOTE_BASE/$dirname" - touch "$REMOTE_BASE/$item" -EOC - - scp "$BASEFOLDER/$item" "$REMOTE:$REMOTE_BASE/$TMPFILE" - silentSsh $REMOTE <<EOS - mv "$REMOTE_BASE/$TMPFILE" "$REMOTE_BASE/$item" -EOS -done diff --git a/dangling-archive b/dangling-archive deleted file mode 100755 index e9a66c2..0000000 --- a/dangling-archive +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# Archive dangling files. -# - -# Parameters -DATE="`date +%Y%m%d%I%M%S`" -LOAD="$HOME/load" -IMAGES="$HOME/data/images/incoming" -IMAGES_PATTERN=".*\.(png|jpg|jpeg|gif|svg)" -DOC="$HOME/data/doc/incoming" -DOC_PATTERN=".*\.(txt|doc|docx|rtf|pdf|sxc|csv|odt|odf|ods|xls|xlsx|ppt|epub|mobi|djvu|lit)" -NOISE="$HOME/data/noise/incoming" -NOISE_PATTERN=".*\.(mp3|ogg|opus|m4a)" -VIDEO="$HOME/data/video/incoming" -VIDEO_PATTERN=".*\.(mp4|mov|mkv|avi|srt|mpg)" -FIND_OPTS="-maxdepth 1 -regextype posix-egrep -iregex" - -# Ensure all folders exist -mkdir -p $LOAD $IMAGES $DOC - -# Move images -if [ "`find $LOAD/ $FIND_OPTS "$IMAGES_PATTERN" | wc -l`" != "0" ]; then - echo "Moving images into $IMAGES/$DATE ..." - mkdir -p $IMAGES/$DATE - find $LOAD/ $FIND_OPTS "$IMAGES_PATTERN" -exec mv {} $IMAGES/$DATE/ \; -fi - -# Move doc -if [ "`find $LOAD/ $FIND_OPTS "$DOC_PATTERN" | wc -l`" != "0" ]; then - echo "Moving docs into $DOC/$DATE ..." - mkdir -p $DOC/$DATE - find $LOAD/ $FIND_OPTS "$DOC_PATTERN" -exec mv {} $DOC/$DATE/ \; -fi - -# Move noise -if [ "`find $LOAD/ $FIND_OPTS "$NOISE_PATTERN" | wc -l`" != "0" ]; then - echo "Moving noise into $NOISE/$DATE ..." - mkdir -p $NOISE/$DATE - find $LOAD/ $FIND_OPTS "$NOISE_PATTERN" -exec mv {} $NOISE/$DATE/ \; -fi - -# Move video -if [ "`find $LOAD/ $FIND_OPTS "$VIDEO_PATTERN" | wc -l`" != "0" ]; then - echo "Moving video into $VIDEO/$DATE ..." - mkdir -p $VIDEO/$DATE - find $LOAD/ $FIND_OPTS "$VIDEO_PATTERN" -exec mv {} $VIDEO/$DATE/ \; -fi @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Dictionary wrapper. -# - -# Parameters -BASENAME="`basename $0`" -DICT="/usr/bin/dict" - -# Dispatch -if [ -x "$DICT" ]; then - $DICT "$@" -else - if which surfraw &> /dev/null; then - surfraw wiktionary "$@" - else - echo "error: no suitable dictionary found in the system" - exit 1 - fi -fi diff --git a/doi2bib b/doi2bib deleted file mode 100755 index 1c26d21..0000000 --- a/doi2bib +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python3 -# Adapted from https://scipython.com/blog/doi-to-bibtex/ - -import sys -import pycurl -from io import BytesIO -#import urllib.request -#from urllib.error import HTTPError - -BASE_URL = 'http://dx.doi.org/' - -try: - doi = sys.argv[1] -except IndexError: - print('Usage:\n{} <doi>'.format(sys.argv[0])) - sys.exit(1) - -url = BASE_URL + doi - -# Urllib version -#req = urllib.request.Request(url) -#req.set_proxy('socks5://localhost:9050', 'socks') -#req.add_header('Accept', 'application/x-bibtex') - -# PyCurl version with Tor support -# See http://pycurl.io/docs/latest/quickstart.html -buffer = BytesIO() -req = pycurl.Curl() -req.setopt(req.URL, url) -req.setopt(req.HTTPHEADER, ('Accept: application/x-bibtex',)) -req.setopt(req.FOLLOWLOCATION, True) -req.setopt(req.WRITEDATA, buffer) -req.setopt(req.PROXY, 'socks5://localhost:9050') - -try: - #with urllib.request.urlopen(req) as f: - # bibtex = f.read().decode() - #print(bibtex) - - req.perform() - req.close() - body = buffer.getvalue() - - # Body is a byte string. - # We have to know the encoding in order to print it to a text file - # such as standard output. - print(body.decode('iso-8859-1')) -except HTTPError as e: - if e.code == 404: - print('DOI not found.') - else: - print('Service unavailable.') - sys.exit(1) diff --git a/dupbackup b/dupbackup deleted file mode 100755 index f020c36..0000000 --- a/dupbackup +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# -# dupbackup: duplicity wrapper -# feedback: rhatto at riseup.net -# -# dupbackup is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or any later version. -# -# common.sh is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 59 Temple -# Place - Suite 330, Boston, MA 02111-1307, USA - -# Usage: dupbackup <host> [option] - -USER="`whoami`" -LOCAL_FOLDER="/mnt/crypt/home/$USER/" -REMOVE_OLDER_THAN="3M" -KEY="" -HOST="$1" -OPTION="$2" - -# Load configuration -if [ -e "$HOME/.config/scripts/dupbackup" ]; then - source $HOME/.config/scripts/dupbackup -fi - -if [ ! -z "$HOST" ]; then - DEST="/var/backups/remote/$USER/duplicity" - DEST="scp://$USER@$HOST/$DEST" -else - DEST="file:///var/backups/users/$USER/duplicity" -fi - -if [ -z "$OPTION" ]; then - OPTION="incr" -fi - -mkdir -p $LOCAL_FOLDER/tmp/duplicity - -duplicity $OPTION -v6 --full-if-older-than $REMOVE_OLDER_THAN \ - --allow-source-mismatch --encrypt-key $KEY \ - --sign-key $KEY $LOCAL_FOLDER $DEST \ - --tempdir $LOCAL_FOLDER/tmp/duplicity \ - --exclude $LOCAL_FOLDER/tmp/duplicity - -duplicity remove-older-than $REMOVE_OLDER_THAN $DEST --force diff --git a/export-firefox-bookmarks b/export-firefox-bookmarks deleted file mode 100755 index 45878dd..0000000 --- a/export-firefox-bookmarks +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -# -# Export Mozilla Firefox bookmarks. -# Based on https://github.com/pirate/ArchiveBox/blob/master/bin/export_browser_history.sh -# - -# Parameters -BASENAME="`basename $0`" -BASEDIR="$HOME/.mozilla/firefox" -PROFILES="$BASEDIR/profiles" -PROFILE="$1" -#SECTION="moz_${2:-bookmarks}" - -# Export from a single database -function export_firefox_bookmark { - sqlite3 $1 "SELECT \"[\" || group_concat(json_object('timestamp', b.dateAdded, 'description', b.title, 'href', f.url)) || \"]\" FROM moz_bookmarks AS b JOIN moz_places AS f ON f.id = b.fk" -} - -# Check -#if [ ! -e "$BASEDIR/profiles.ini" ]; then -# echo "$BASENAME: not found: $BASEDIR/profiles.ini" -# exit 1 -#fi - -#PROFILES="grep "^Name=" $BASEDIR/profiles.ini | cut -d = -f 2 | xargs" - -# There might be many places.sqlite on many profiles -if [ -z "$PROFILE" ]; then - find $BASEDIR -name places.sqlite | while read file; do \ - export_firefox_bookmark $file - done -else - # Assumption: when a $PROFILE is given, search at $PROFILES - if [ -e "$PROFILES/$PROFILE/places.sqlite" ]; then - export_firefox_bookmark $PROFILES/$PROFILE/places.sqlite - else - echo "$BASENAME: file not found: $PROFILES/$PROFILE/places.sqlite" - exit 1 - fi -fi diff --git a/export-koreader-note b/export-koreader-note deleted file mode 100755 index ae2e0ef..0000000 --- a/export-koreader-note +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env lua --- --- Convert koreader metadata to markdown. --- - --- Sort by page number -function compare(a, b) - return a.page < b.page -end - --- Check if a file exists --- Thanks https://stackoverflow.com/questions/4990990/check-if-a-file-exists-with-lua#4991602 -function file_exists(name) - local f=io.open(name,"r") - if f~=nil then io.close(f) return true else return false end -end - --- Get filename -file = arg[1] - --- Usage -if file == nil then - print('usage: ' .. arg[0] .. ' <filename>') - os.exit(1) -else - if not file_exists(file) then - print('file not found: ' .. file) - os.exit(1) - end -end - --- Load metadata -content = assert(loadfile(file)) -data = content() -bookmarks = data.bookmarks - --- Sort -table.sort(bookmarks, compare) - --- Iterate over bookmarks -for key, item in ipairs(bookmarks) do - print('Page ' .. item.page .. ':') - print('') - print('> ' .. item.notes) - print('') -end diff --git a/export-pad b/export-pad deleted file mode 100755 index fd17d2a..0000000 --- a/export-pad +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# -# Export etherpad content into a file. -# - -# Parameters -URL="$1" -FILE="$2" -BASENAME="`basename $0`" - -# Check -if [ -z "$FILE" ]; then - echo "usage: $BASENAME <url> <file>" - exit 1 -fi - -# Dispatch -torify curl $URL/export/txt > $FILE @@ -1,18 +0,0 @@ -#!/bin/bash -# -# FIXME visualizer. -# Run on itself for a nice result: fixmes `which fixmes` -# - -# Basic params -NAME="$0" -BASENAME="`basename $NAME`" - -# Run -if [ ! -z "$1" ] && [ -e "$1" ]; then - file="$1" -else - file='-R *' -fi - -grep -i "FIXME" $file | sed -e 's/^ *//' diff --git a/gallery b/gallery deleted file mode 100755 index 45e46eb..0000000 --- a/gallery +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# -# Image galleries: a wrapper for sxiv(1). -# - -# Parameters -BASENAME="`basename $0`" -IMAGES="$HOME/data/images" -GALLERY="${1:-$IMAGES}" - -# Check -if [ "$GALLERY" != "-" ] && [ ! -d "$GALLERY" ]; then - echo "$BASENAME: path not found: $GALLERY" - exit 1 -elif ! which sxiv &> /dev/null; then - echo "$BASENAME: please install sxiv" - exit 1 -fi - -# Dispatch -# Option -o allows piping the selection output to other tools -sxiv -t -q -b -o -r $GALLERY 2> /dev/null diff --git a/icalbuddy b/icalbuddy deleted file mode 100755 index d9e048d..0000000 --- a/icalbuddy +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# This is a placeholder command so xcal does not give errors when calling icalbuddy -# See https://github.com/alxppp/xcal -# http://hasseg.org/icalBuddy/ - -# Do nothing, successfully -/bin/true diff --git a/keyringer-export-pads b/keyringer-export-pads deleted file mode 100755 index 167c3a6..0000000 --- a/keyringer-export-pads +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# Export etherpad content into a keyring. -# This is currently too specific to be added into keyringer tree. -# - -# Load functions -#LIB="`dirname $0`/../functions" -#source "$LIB" maintenance $* || exit 1 - -# Parameters -BASENAME="`basename $0`" -KEYRING="$1" -PAD="$2" - -# Procedure -function keyringer_export_pad { - torify curl `keyringer $KEYRING decrypt pads/urls/$1 main 2> /dev/null`/export/txt | keyringer $KEYRING encrypt pads/exports/$1 -} - -# Check -if [ -z "$KEYRING" ]; then - echo "usage: $BASENAME <keyring> [pad]" - exit 1 -fi - -# Dispatch -if [ -z "$PAD" ]; then - for pad in `keyringer $KEYRING ls pads/urls`; do - echo "Exporting $pad..." - done -else - echo "Exporting $PAD..." - keyringer_export_pad $PAD -fi diff --git a/luakit-adblock-update b/luakit-adblock-update deleted file mode 120000 index 42263c4..0000000 --- a/luakit-adblock-update +++ /dev/null @@ -1 +0,0 @@ -/home/rhatto/.config/luakit/contrib/luakit-plugins/tools/adblock-update.sh
\ No newline at end of file @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Move a file but keep a symlink behind. -# -# See http://www.linuxquestions.org/questions/linux-newbie-8/script-to-move-old-files-create-symbolic-link-728618/ -# http://lifehacker.com/5270634/move-files-without-breaking-stuff -# https://stackoverflow.com/questions/9251818/bash-move-file-directory-and-create-a-link-of-it -# http://serverfault.com/questions/8108/move-a-file-and-leave-a-soft-link-behind - -# Parameters -BASE="$(basename "$1")" -ORIG="$(dirname "$1")" -DEST="$2" - -# Check -if [ ! -e "$ORIG/$BASE" ]; then - echo "File not found: $ORIG/$BASE" - exit 1 -fi - -# Proceed -mkdir -p "$DEST" -mv "$ORIG/$BASE" "$DEST" && ln -s "$DEST/$BASE" "$ORIG/$BASE" diff --git a/openvpn-resolv-conf b/openvpn-resolv-conf deleted file mode 100755 index 48d83ca..0000000 --- a/openvpn-resolv-conf +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# -# Parses DHCP options from OpenVPN to update resolv.conf. -# To use set as 'up' and 'down' script in your openvpn config: -# up /etc/openvpn/update-resolv-conf -# down /etc/openvpn/update-resolv-conf -# -# credit: -# * Thomas Hood <jdthood@yahoo.co.uk> -# * Chris Hanson -# * chlauber@bnc.ch -# -# Licensed under the GNU GPL -# - -[ -x /sbin/resolvconf ] || exit 0 - -case $script_type in - up) - for optionname in ${!foreign_option_*} ; do - option="${!optionname}" - echo $option - part1=$(echo "$option" | cut -d " " -f 1) - if [ "$part1" == "dhcp-option" ] ; then - part2=$(echo "$option" | cut -d " " -f 2) - part3=$(echo "$option" | cut -d " " -f 3) - if [ "$part2" == "DNS" ] ; then - IF_DNS_NAMESERVERS="$IF_DNS_NAMESERVERS $part3" - fi - if [ "$part2" == "DOMAIN" ] ; then - IF_DNS_SEARCH="$part3" - fi - fi - done - R="" - if [ "$IF_DNS_SEARCH" ] ; then - R="${R}search $IF_DNS_SEARCH\n" - fi - for NS in $IF_DNS_NAMESERVERS ; do - R="${R}nameserver $NS" - done - echo -n "$R" | /sbin/resolvconf -a "${dev}.inet" - ;; - down) - /sbin/resolvconf -d "${dev}.inet" - ;; -esac diff --git a/powersaving b/powersaving deleted file mode 100755 index 75c5605..0000000 --- a/powersaving +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# from https://geoff.greer.fm/2017/07/16/thinkpad-x62/ - -# Disable the NMI watchdog -echo '0' > '/proc/sys/kernel/nmi_watchdog'; - -# Runtime power management for I2C devices -for i in /sys/bus/i2c/devices/*/device/power/control ; do - echo auto > ${i} -done - -# Runtime power-management for PCI devices -for i in /sys/bus/pci/devices/*/power/control ; do - echo auto > ${i} -done - -# Runtime power-management for USB devices -for i in /sys/bus/usb/devices/*/power/control ; do - echo auto > ${i} -done - -# Low power SATA -for i in /sys/class/scsi_host/*/link_power_management_policy ; do - echo min_power > ${i} -done - -# Disable Wake-on-LAN on ethernet port -#ethtool -s wlan0 wol d; -#ethtool -s eth0 wol d - -#Enable Audio codec power management -echo '1' > '/sys/module/snd_hda_intel/parameters/power_save'; - -# Low power wireless -iw dev wlan0 set power_save on @@ -1,6 +0,0 @@ -#!/bin/bash -# -# Simple password generator. -# - -head -c ${1:-20} /dev/urandom | base64 diff --git a/reminders b/reminders deleted file mode 100755 index a92ae83..0000000 --- a/reminders +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -# Print a short summary of today's reminders. - -if [ -e "$HOME/.reminders" ]; then - cd - remind $HOME/.reminders $* | grep -v '^No reminders.$' | sed -e '/^$/d' -fi diff --git a/screenshot b/screenshot deleted file mode 100755 index 75a9895..0000000 --- a/screenshot +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# Wrapper around scrot - -# Workaround -# See https://bbs.archlinux.org/viewtopic.php?id=86507 -# https://groups.google.com/forum/#!msg/linux.debian.bugs.dist/_tmJIFYBfZo/F7x5WFEQCMsJ -if echo "$*" | grep -q -- '-s'; then - sleep 0.2 -fi - -# Take a screenshot -scrot '%Y-%m-%d-%H:%M:%S_$wx$h.png' -e 'mv $f ~/load/' $* diff --git a/scuttle b/scuttle deleted file mode 100755 index e065b48..0000000 --- a/scuttle +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# Post a link to a scuttle service. -# - -# Thanks https://gist.github.com/cdown/1163649 -function urlencode() { - # urlencode <string> - old_lc_collate=$LC_COLLATE - LC_COLLATE=C - - local length="${#1}" - for (( i = 0; i < length; i++ )); do - local c="${1:i:1}" - case $c in - [a-zA-Z0-9.~_-]) printf "$c" ;; - *) printf '%%%02X' "'$c" ;; - esac - done - - LC_COLLATE=$old_lc_collate -} - -# Parameters -BASENAME="`basename $0`" -URL="$1" -TAGS="$2" -shift 2 -DESC="$*" -TMP="${TMP:=/tmp}" - -# Syntax -if [ -z "$TAGS" ]; then - echo "usage: $BASENAME <url> <tags> [description]" - exit -fi - -# Config -source "$HOME/.custom/scuttle" || exit 1 - -# See http://www.wired.com/2010/02/using_the_delicious_api/ -#CALL="$SCUTTLE_URL/api/posts/add?url=`urlencode $URL`" -CALL="$SCUTTLE_URL/api/posts/add" - -# Tags -TAGS="`echo $TAGS | sed -e 's/,/ /g'`" -#TAGS="`urlencode "$TAGS"`" -TAGS="`echo $TAGS | sed -e 's/%2C/,/g'`" -#CALL="$CALL&tags=$TAGS" - -# Description -if [ -z "$DESC" ]; then - # See http://stackoverflow.com/questions/3195851/ddg#3195895 - DESC="`torify curl -L -s $URL | grep -i "<title>" | sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q' 2> /dev/null`" - echo "Fetched description: $DESC" -fi - -# Full API call -#CALL="$CALL&description=`urlencode "$DESC"`" - -# Write config -CONF="`mktemp -t scuttle.XXXXXXXXXX -p $TMP`" -echo "url = $CALL" > $CONF -echo "user = $SCUTTLE_USER:$SCUTTLE_PASS" >> $CONF - -# Remove trailing slash which might lead to urlencode errors by curl (dunny why) -URL="`echo $URL | sed -e 's|/$||'`" - -# Call curl -# See https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command#2027690 -#curl -s -K $CONF &> /dev/null -curl -s -K $CONF -G --data-urlencode "url=$URL" --data-urlencode "tags=$TAGS" --data-urlencode "description=$DESC" &> /dev/null - -# Status -STATUS="$?" - -# Teardown -rm $CONF -exit $STATUS @@ -1,119 +0,0 @@ -#!/bin/bash -# -# Fast way to browse documents stored in an archive. -# - -# Parameters -PROGRAM="$0" -BASENAME="`basename $0`" -DOCS="$HOME/data/doc" -BIBLIO="$DOCS/bibliographies" -FILELIST=".filelist" -LIST="$DOCS/$FILELIST" -DOC_PATTERN=".*\.(txt|doc|docx|rtf|pdf|sxc|csv|odt|odf|ods|xls|xlsx|ppt|epub|mobi|djvu|lit)" -FIND_OPTS="-not -path '*.git*' -regextype posix-egrep -iregex" -ARG="$1" -EXTRA_ARG="$2" -DATE="`date +%s`" -MAX_AGE="86400" - -# Update the filelist -function __update_filelist { - echo "Generating new filelist..." - - # Unnanex if it was erroneously annexed - if [ -h "$LIST" ] && [ -d "$DOCS/.git/annex" ]; then - ( cd $DOCS && git annex unlock $FILELIST ) - fi - - # Refresh - cd $DOCS && find . $FIND_OPTS "$DOC_PATTERN" > $LIST - - # Stage - git add $LIST -} - -# Check -if [ -z "$ARG" ]; then - echo "usage: $BASENAME [option] [<object>] [extra-args]" - echo " $BASENAME --refresh" - echo " $BASENAME --<program-name> <item-name>" - echo " $BASENAME --open <item-name>" - echo " $BASENAME --rifle <item-name> -p 4" - echo " $BASENAME --koreader <item-name>" - echo " $BASENAME --watch <subfolder>" - echo " $BASENAME <item-name>" - exit 1 -elif [ "$ARG" == "--refresh" ]; then - __update_filelist -elif [ ! -d "$DOCS" ]; then - echo "missing $DOCS folder" - exit 1 -fi - -# Check for filelist -if [ ! -e "$LIST" ]; then - __update_filelist - CHANGED="`date +%s`" -else - CHANGED="`stat --printf='%Y\n' $LIST`" -fi - -# Automatically refresh lists older than $MAX_AGE -#if ((($DATE - $CHANGED) >= $MAX_AGE)); then -# __update_filelist -#fi - -# Dispatch -#find $DOCS -iname "*$ARG*" | head -1 | while read entry; do xdg-open "$entry"; done -if [ "$ARG" == "--search" ]; then - shift - grep -i -- "$*" $LIST -elif [ "$ARG" == "--details" ]; then - shift - entry="`echo $* | sed -e 's/^@//'`" - if grep -qiR -- "$entry" $BIBLIO; then - grep -iR -- "$entry" $BIBLIO | cut -d : -f 1 | while read file; do - echo "At $file:" - echo "" - # Thanks https://tex.stackexchange.com/questions/28506/how-to-use-a-command-line-tool-to-extract-a-bibtex-reference-that-contains-a-sea - awk -v RS='\n@' "/${entry}/" $file - done - else - find $DOCS -name ${1}.bib -exec cat {} \; - fi -elif [ "$ARG" == "--watch" ]; then - # Convert symlink to full path and start inotifywait loop - folder="`readlink -f $DOCS`" - subfolder="$EXTRA_ARG" - echo "Watching changes at $folder/$subfolder..." - - #while inotifywait -e modify -e create -e move -e delete -r "$folder"; do - #while inotifywait -e modify -e move -r "$folder"; do - #while inotifywait -e modify -e move -r "$folder/$subfolder"; do - while inotifywait -e modify -e create -e move -e delete -r "$folder/$subfolder"; do - $PROGRAM --refresh - done -else - shift 2 - EXTRA_ARGS="$*" - - # Allows for specifying a custom command to open the file - if [ "${ARG:0:2}" == "--" ] && [ ! -z "$EXTRA_ARG" ]; then - OPEN="${ARG:2}" - ARG="$EXTRA_ARG" - - # Shortcuts for xdg-open - if [ "$OPEN" == "open" ] || [ "$OPEN" == "read" ]; then - OPEN="xdg-open" - fi - else - OPEN="xdg-open" - EXTRA_ARGS="" - fi - - grep -i -- "$ARG" $LIST | while read entry; do - echo "Opening $entry..." - cd $DOCS && $OPEN $EXTRA_ARGS "$entry" - done -fi diff --git a/sri-hash b/sri-hash deleted file mode 100755 index 5979c39..0000000 --- a/sri-hash +++ /dev/null @@ -1,34 +0,0 @@ -#/bin/sh -# -# SRI Hash Generator -# - -# Parameters -BASENAME="`basename $0`" -URI="$1" - -# Check -if [ -z "$URI" ]; then - echo "usage: $BASENAME <file-or-url>" - exit 1 -fi - -# Get file -if echo "$URI" | grep -q '^http'; then - echo "downloading $URI and generating hash..." - HASH="`curl $URI | openssl dgst -sha384 -binary | openssl base64 -A`" - echo "" -else - if [ -e "$URI" ]; then - # See https://www.srihash.org/ - HASH="`openssl dgst -sha384 -binary $URI | openssl base64 -A`" - else - echo "file not found: $URI" - exit 1 - fi -fi - -# Generate -cat <<EOF -<script src="$URI" integrity="sha384-$HASH" crossorigin="anonymous"></script> -EOF @@ -1,146 +0,0 @@ -#!/bin/bash -# -# Check the overall status of your work. -# - -# Parameters -BASENAME="`basename $0`" - -# Usage -function status_usage { - echo "usage: $BASENAME [-l|--long] [-d|--delay N] [project]" - - if [ -z "$1" ]; then - exit 1 - else - exit $1 - fi -} - -# See https://stackoverflow.com/questions/2721946/cross-platform-getopt-for-a-shell-script#4300224 -function status_options { - getopt -T > /dev/null - if [ $? -eq 4 ]; then - # GNU enhanced getopt is available - ARGS=`getopt --name "$BASENAME" --long loop,delay: --options ld: -- "$@"` - else - # Original getopt is available (no long option names, no whitespace, no sorting) - ARGS=`getopt ld: "$@"` - fi - - if [ $? -ne 0 ]; then - echo "$BASENAME: usage error" >&2 - status_usage 2 - fi - - eval set -- $ARGS - - while [ $# -gt 0 ]; do - case "$1" in - l|--loop) - LOOP="yes";; - d|--delay) - DELAY="$2" - shift;; - --) - shift - break;; - *) - status_usage - ;; - esac - shift - done - - if [ $# -gt 0 ]; then - PROJECT="$1" - shift - fi -} - -# Run status -function status_run { - if [ ! -z "$PROJECT" ]; then - # Check the status of the given project - cd $PROJECT &> /dev/null && git status - elif git status &> /dev/null; then - # Check the status of the current project - mr status - else - # Ensure we are in the home folder - cd - - # Check your reminders - if which remind &> /dev/null && [ -e "$HOME/.reminders" ]; then - remind ~/.reminders | grep -iv '^no reminders.$' # | tr '[:upper:]' '[:lower:]' - fi - - # Update your mrconfig and check all registered repositories - if which mr &> /dev/null; then - # Pipe through cat so we don't have to deal with mr's dynamic output weirdness - #mrconfig-updater && mr -m status | cat - - # Replace eventual "/mnt/crypt/home/$USER" with "~/" from output - # Piping through sed also handles mr's dynamic output weirdness - mrconfig-updater && mr -m status | sed -e "s|/mnt/crypt/home/$USER/|~/|" -e "s|$HOME|~|" - fi - - # Use this as an opportunity to save our configs - if which git-config-save &> /dev/null; then - git config-save --sometimes &> /dev/null - fi - - # Check your TODO lists, filtering only important tasks - # Convention here is to use uppercase "IMPORTANT", to be explicit and avoid false positives - todo list IMPORTANT - - # Collected items that need to be moved somewhere else - collector list - - # Check if you have mails to send - postponed - - # Check unread mails - unread-mails - - # Alarms set - #xalarm list - - # Check for spool files - if [ -e "$HOME/temp/log/spool.md" ] && [ "`wc -l $HOME/temp/log/spool.md | cut -d ' ' -f 1`" != "0" ]; then - echo "Spool file not empty: $HOME/temp/log/spool.md" - fi - - # Check if are dangling downloaded files - if [ -e "$HOME/load" ] && [ ! -z "`ls -1 ~/load/`" ]; then - # Print a newline if needed depending of the output of the previous commands - if [ ! -z "`postponed`" ] || [ ! -z "`unread-mails`" ] || [ ! -z "`collector list`" ]; then - echo "" - fi - - echo "Dangling files at ~/load:" - echo "" - ls -lh ~/load/ - fi - fi -} - -# Options -status_options $@ - -# Dispatch -if [ "$LOOP" == "yes" ]; then - PROJECT="" - - if [ -z "$DELAY" ]; then - DELAY="60" - fi - - while true; do - clear - status_run - sleep $DELAY - done -else - status_run -fi @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# -# A shorthand for changing to a user -# - -# Parameters -BASENAME="`basename $0`" -USER="$1" - -if [ -z "$USER" ]; then - echo "usage: $BASENAME <user>" - exit 1 -fi - -sudo su $USER -s $SHELL diff --git a/sync-from-kobo b/sync-from-kobo deleted file mode 100755 index 74b89ef..0000000 --- a/sync-from-kobo +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# A mini-wrapper to sync a kobo folder into a local one. -# - -# Parameters -BASENAME="`basename $0`" -BASEFOLDER="$HOME/data/doc" -COLLECTION="$1" - -# Check -if [ -z "$COLLECTION" ]; then - echo "usage: $BASENAME <colletion>" - echo "available collections:" - echo "" - ls $BASEFOLDER - exit 1 -fi - -# Ensure collection exists -if [ ! -d "$BASEFOLDER/$COLLECTION" ]; then - echo "error: no such collection $COLLECTION at $BASEFOLDER" - exit 1 -fi - -# Setup origin -if [ "$COLLECTION" == "clipboard" ]; then - ORIGIN="/mnt/onboard/.adds/koreader/clipboard" -else - ORIGIN="/mnt/sd/$COLLECTION" -fi - -# Dispatch -lftp -c "open sftp://kobo && mirror -L $ORIGIN $BASEFOLDER/$COLLECTION" diff --git a/sync-to-kobo b/sync-to-kobo deleted file mode 100755 index 8d62859..0000000 --- a/sync-to-kobo +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# A mini-wrapper to sync a local folder into kobo. -# - -# Parameters -BASENAME="`basename $0`" -BASEFOLDER="$HOME/data/doc" -COLLECTION="$*" - -# Check -if [ -z "$COLLECTION" ]; then - echo "usage: $BASENAME <colletion>" - echo "available base collections:" - echo "" - ls $BASEFOLDER - exit 1 -fi - -# Ensure collection exists -if [ ! -d "$BASEFOLDER/$COLLECTION" ]; then - echo "error: no such collection $COLLECTION at $BASEFOLDER" - exit 1 -fi - -# Dispatch -# Use --exclude with a egrep regexp -lftp -c "open sftp://kobo && mirror --exclude=.*sdr --delete -L -R \"$BASEFOLDER/$COLLECTION\" \"/mnt/sd/$COLLECTION\"" @@ -1,14 +0,0 @@ -#!/bin/bash -# -# A very simple taskwarrior wrapper. -# - -# Parameters -TASK="/usr/bin/task" - -# Dispatch -if [ -e ".task" ]; then - $TASK rc.data.location=.task "${@}" -else - $TASK "${@}" -fi @@ -1,57 +0,0 @@ -#!/bin/bash -# -# A taskwarrior wrapper. -# - -# Basic params -CONFIG="$HOME/.config/tasks" -BASENAME="`basename $0`" -PROJECT="$1" - -# Config -if [ -e "$CONFIG" ] ; then - source $CONFIG -fi - -# Custom params -TODO_MAXDEPTH="2" -WORKPATH="${WORKPATH:=~/}" -FOLDERS="`echo $WORKPATH | tr ':' ' ' | sed -e "s|~|$HOME|g"`" - -# Check if first param is a project -if [ ! -z "$PROJECT" ] && cd $PROJECT &> /dev/null || false; then - IS_PROJECT="true" - shift -else - IS_PROJECT="false" -fi - -cd - &> /dev/null - -# Check if project exists -if [ "$IS_PROJECT" == "true" ]; then - cd $PROJECT &> /dev/null || exit 1 - - # Get full path - CWD="`pwd`" - - # Call taskwarrior - if [ -d "$CWD/.task" ]; then - task rc.data.location=$CWD/.task rc.verbose=nothing $* - fi -else - for folder in $FOLDERS; do - if [ ! -d "$folder" ]; then - continue - fi - - find $folder/ -maxdepth $TODO_MAXDEPTH -xtype d -iname '.task' | while read task; do - if [ -z "$SILENT" ]; then - echo "Tasks from $task:" - echo "" - fi - - task rc.data.location=$task rc.verbose=nothing $* - done - done -fi diff --git a/telneter b/telneter deleted file mode 100755 index acb9404..0000000 --- a/telneter +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/expect -# -# Simple telnet application to log in a server -# WARNING: passphrase is sent in the clear! -# - -spawn telnet example.org -# Not absolutely necessary, but good to keep the spawn_id for later -set telnet $spawn_id -# Case insensitive, just in case.. -expect -nocase "login:" -send "user\r" -# My telnetd insisted on an uppercase P. This works bothways -expect -nocase "password:" -send "SENHA\r" -# Match the prompt (contains a $) -expect -re {\$} -# Get the environment variables -send "env\r" -# Wait for the prompt -expect -re {\$} -exit diff --git a/timew-shell b/timew-shell deleted file mode 100755 index 2ebbf28..0000000 --- a/timew-shell +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# Timewarrior shell. -# - -# Shell -function timew_shell { - local last_exit_code="0" - - # While a "quit" command isn't entered, read STDIN - while read -rep "$last_exit_code timew> " STDIN; do - history -s "$STDIN" - - if [ "$STDIN" == "quit" ] || [ "$STDIN" == "exit" ] || [ "$STDIN" == "bye" ]; then - break - elif [[ -n "$STDIN" && "$STDIN" != "#"* ]]; then - # If line is not empty or commented, process command - STDIN=($STDIN) - - if [ "$STDIN" == "status" ] || [ "$STDIN" == "st" ]; then - timew - else - timew ${STDIN[@]} - fi - - last_exit_code="$?" - fi - done -} - -# Dispatch -timew_shell @@ -1,120 +0,0 @@ -#!/bin/bash -# -# Task list visualizer. -# - -# Basic params -CONFIG="$HOME/.config/todo" -NAME="$0" -BASENAME="`basename $NAME`" -OPTION="$1" - -# Config -if [ -e "$CONFIG" ] ; then - source $CONFIG -fi - -# Custom params -TODO_MAXDEPTH="2" -WORKPATH="${WORKPATH:=~/}" -FOLDERS="`echo $WORKPATH | tr ':' ' ' | sed -e "s|~|$HOME|g"`" - -# Iterate -function todo_find { - for folder in $FOLDERS; do - if [ ! -d "$folder" ]; then - continue - fi - - find $folder/ -maxdepth $TODO_MAXDEPTH -xtype f -iname 'todo*' | while read todo; do - # Ignore lists without tasks - if grep -q -e '\* \[ \]' -e '-' $todo; then - echo $todo - fi - done - done -} - -function todo_list { - local status="$1" - - # User's Taskwarrior - if which task &> /dev/null; then - if [ "`task status:pending count 2> /dev/null`" != "0" ]; then - echo "taskwarrior:" - #echo "" - task list 2> /dev/null - echo "" - fi - - # Taskwarrior data from projects - if [ ! -z "$status" ]; then - taskstatus="+$status" - SILENT="true" - fi - - SILENT=$SILENT tasks $taskstatus list 2> /dev/null - echo "" - fi - - # User's Timewarrior - if which timew &> /dev/null; then - if ! timew | grep -q "^There is no active time tracking."; then - timew - echo "" - fi - fi - - todo_find | while read todo; do - if [ "$todo" != "$NAME" ]; then - if [ ! -z "$status" ] && ! grep -q "\($status\)" $todo; then - continue - fi - - path="`echo $todo | sed -e "s|^$HOME|~|"`" - delim="===`echo $path | sed -e 's|.|=|g'`" - #echo "" - echo In $path - echo $delim - echo "" - - if [ ! -z "$status" ]; then - if echo $todo | grep -q $status; then - grep -e '\* \[ \]' -e '-' $todo - else - grep -e '\* \[ \]' -e '-' $todo | grep "\($status\)" - fi - else - grep -e '\* \[ \]' -e '-' $todo - fi - - echo "" - fi - done -} - -if [ "$OPTION" == "find" ]; then - todo_find | grep -v -e "^$NAME$" | sed -e "s|^$HOME|~|" -elif [ "$OPTION" == "count" ]; then - todo_find | grep -v $NAME | wc -l -elif [ "$OPTION" == "show" ] || [ "$OPTION" == "see" ] || [ "$OPTION" == "view" ]; then - if [ ! -z "$2" ] && [ -e "$2" ]; then - # Check TODO inside files - grep -i "todo" $2 | sed -e 's/^ *//' - - # Check also for FIXMEs - fixmes $2 - elif cd $2 &> /dev/null; then - ( - cd $2 &> /dev/null - find -maxdepth 1 -xtype f -iname 'todo*' -exec cat {} \; | grep -e '*' -e '-' - ) - fi -elif [ "$OPTION" == "list" ]; then - todo_list $2 -elif [ "$OPTION" == "help" ]; then - echo "usage: $BASENAME [list|count]" - echo " $BASENAME <show|see|view> <file|project>" -else - todo_list -fi diff --git a/tomb-close b/tomb-close deleted file mode 100755 index 3ee08dd..0000000 --- a/tomb-close +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# Close a Tomb. -# - -# Parameters -TOMBS="$HOME/data/tombs" -KEYS="$HOME/.tombs" -BASENAME="`basename $0`" -TOMB="$1" - -# Check -if [ ! -d "$TOMBS" ]; then - echo "error: no cemetery available at $TOMBS" - exit 1 -elif [ -z "$TOMB" ]; then - echo "usage: $BASENAME <tomb>" - echo "available tombs: `ls $TOMBS | xargs basename -a -s .tomb | xargs echo`" - exit 1 -elif [ ! -e "$TOMBS/$TOMB.tomb" ]; then - echo "tomb not found: $TOMBS/$TOMB.tomb" - exit 1 -#elif ! tomb list $TOMB &> /dev/null; then -# echo "tomb $TOMB is already closed" -# exit 1 -fi - -# Dispatch -tomb close $TOMB - -# Annex -if [ -d "$TOMBS/.git/annex" ]; then - ( cd $TOMBS && git annex add $TOMB.tomb ) -fi diff --git a/tomb-create b/tomb-create deleted file mode 100755 index aa211c2..0000000 --- a/tomb-create +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -# -# Create a Tomb. -# - -# Parameters -TOMBS="$HOME/data/tombs" -KEYS="$HOME/.tombs" -BASENAME="`basename $0`" -TOMB="$1" -SIZE="$2" - -# Check -if [ ! -d "$TOMBS" ]; then - echo "error: no cemetery available at $TOMBS" - exit 1 -elif [ -z "$TOMB" ]; then - echo "usage: $BASENAME <tomb>" - exit 1 -elif [ -e "$TOMBS/$TOMB.tomb" ]; then - echo "tomb already exists: $TOMBS/$TOMB.tomb" - exit 1 -elif [ ! -e "$KEYS/$TOMB.tomb.key" ]; then - echo "missing keyfile $KEYS/$TOMB.tomb.key" - exit 1 -fi - -# Set -if [ -z "$SIZE" ]; then - SIZE="16" -fi - -# Create password -keyringer default pwgen tombs/$TOMB.tomb.key.passwd - -# Dispatch -tomb dig $TOMBS/$TOMB.tomb -s $SIZE -tomb forge $KEYS/$TOMB.tomb.key -tomb lock $TOMBS/$TOMB.tomb -k $KEYS/$TOMB.tomb.key - -# Add key into keyringer -keyringer default encrypt tombs/$TOMB.tomb.key $KEYS/$TOMB.tomb.key - -# Annex -#if [ -d "$TOMBS/.git/annex" ] && [ -h "$TOMBS/$TOMB.tomb" ]; then -# ( cd $TOMBS && git annex unlock $TOMB.tomb ) -#fi diff --git a/tomb-open b/tomb-open deleted file mode 100755 index 5154215..0000000 --- a/tomb-open +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# Open a Tomb. -# - -# Parameters -TOMBS="$HOME/data/tombs" -KEYS="$HOME/.tombs" -BASENAME="`basename $0`" -TOMB="$1" - -# Check -if [ ! -d "$TOMBS" ]; then - echo "error: no cemetery available at $TOMBS" - exit 1 -elif [ -z "$TOMB" ]; then - echo "usage: $BASENAME <tomb>" - echo "available tombs: `ls $TOMBS | xargs basename -a -s .tomb | xargs echo`" - exit 1 -elif [ ! -e "$TOMBS/$TOMB.tomb" ]; then - echo "tomb not found: $TOMBS/$TOMB.tomb" - exit 1 -elif [ ! -e "$KEYS/$TOMB.tomb.key" ]; then - echo "missing keyfile $KEYS/$TOMB.tomb.key" - exit 1 -fi - -# Unnanex -if [ -d "$TOMBS/.git/annex" ] && [ -h "$TOMBS/$TOMB.tomb" ]; then - ( cd $TOMBS && git annex unlock $TOMB.tomb ) -fi - -# Dispatch -tomb open $TOMBS/$TOMB.tomb -k $KEYS/$TOMB.tomb.key diff --git a/urlinfo b/urlinfo deleted file mode 100755 index 276a7bd..0000000 --- a/urlinfo +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# Retrieve and set basic URL info. -# - -# Parameters -BASENAME="`basename $0`" -URL="$1" -shift -TAGS="$*" - -# Check -if [ -z "$URL" ]; then - echo "usage: $BASENAME <url> [tag1] ... [tagN]" - exit 1 -fi - -# Dispatch -DESC="`torify curl --max-redirs 10 -L -s $URL | grep -i "<title>" | sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q' 2> /dev/null`" - -# YouTube: -#DESC="`torify curl youtube-dl -e $URL`" - -# Verify -if [ -z "$DESC" ]; then - DESC="$URL" -fi - -# Tag -if [ ! -z "$TAGS" ]; then - IDENTIFIER="$URL $TAGS" -else - IDENTIFIER="$URL" -fi - -# Display -if [ "$BASENAME" == "urlinfo" ]; then - echo "- title: \"$DESC\"" - echo " identifier:" - echo " - $IDENTIFIER" -elif [ "$BASENAME" == "urlmd" ]; then - echo "[$DESC]($URL)" -fi @@ -1 +0,0 @@ -urlinfo
\ No newline at end of file diff --git a/urlsave b/urlsave deleted file mode 100755 index e58245c..0000000 --- a/urlsave +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Save URL info in a file as a simple bookmarking service. -# - -# Parameters -CONFIG="$HOME/.custom/urlsave" - -# Load config -if [ -e "$CONFIG" ]; then - source $CONFIG -fi - -# Check -if [ -z "$URLFILE" ] || [ ! -e "$URLFILE" ]; then - URLFILE="/dev/stdout" -fi - -# Dispatch -echo "" >> $URLFILE -urlinfo $* >> $URLFILE diff --git a/urlssave b/urlssave deleted file mode 100755 index ff0dcf1..0000000 --- a/urlssave +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# -# Save multiple URLs using the same tags. -# - -# Dispatch -while read url; do - echo "Saving $url..." - urlsave $url $* -done @@ -1,80 +0,0 @@ -#!/bin/bash -# -# Wrapper around ssh and vncviewer -# - -# Parameters -BASENAME="`basename $0`" -SERVER="$1" -LOCALPORT="${2:-5901}" -REMOTEPORT="${3:-5901}" - -# Clipboard options -# In practice, clipboard limitations are not working as expected -# So please do not use this script if you don't want to automatically share clipboard with the remote system -# This is probably a bug on xtigervncviewer -VIEWER_OPTS="-AcceptClipboard=off -SendClipboard=off -SetPrimary=off -SendPrimary=off" - -function usage { - echo "usage: $BASENAME <server> [localport] [remoteport]" - cat <<EOF - -setup instructions -================== - -* in the remote: - - sudo apt install tigervnc-standalone-server # install in the remote server - vncpasswd # generate a ~/.vnc/passwd in the remote server - -* in the local box: - - scp <server>:~/.vnc/passwd ~/.vnc/<server>.passwd # copy the secret - $BASENAME <server> # use our magic script to do everything else - -EOF - - exit 1 -} - -# Usage -if [ "$1" == "--help" ]; then - usage -fi - -# Check -if [ -z "$SERVER" ]; then - if [ -h "$HOME/.vnc/default.passwd" ]; then - SERVER="$(basename `readlink $HOME/.vnc/default.passwd` .passwd)" - else - usage - fi -fi - -# Check if vncserver is running in the remote server and start otherwise -ssh $SERVER <<EOF - HOSTNAME="\$(cat /etc/hostname)" - - if [ -e "\$HOME/.vnc/\$HOSTNAME:1.pid" ]; then - PID="\$(cat \$HOME/.vnc/\$HOSTNAME:1.pid)" - - if ! ps \$PID &> /dev/null; then - /usr/bin/vncserver -alwaysshared -dpi 96 -localhost :1 - fi - else - /usr/bin/vncserver -alwaysshared -dpi 96 -localhost :1 - fi -EOF - -# See http://www.g-loaded.eu/2006/11/24/auto-closing-ssh-tunnels/ -# Optional SSH compression -#ssh -C -c blowfish -f -L 5901:127.0.0.1:5901 $SERVER sleep 10 -ssh -f -L $LOCALPORT:127.0.0.1:$REMOTEPORT $SERVER sleep 10 - -# Run VNC client -# Copy $SERVER:~/.vnc/passwd into $HOME/.vnc/$SERVER.passwd for passwordless login -if [ -e "$HOME/.vnc/$SERVER.passwd" ]; then - vncviewer $VIEWER_OPTS -passwd $HOME/.vnc/$SERVER.passwd localhost:$LOCALPORT -else - vncviewer $VIEWER_OPTS localhost:$LOCALPORT -fi diff --git a/weather-forecast b/weather-forecast deleted file mode 100755 index 269f740..0000000 --- a/weather-forecast +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Simple wrapper around wttr.in -# - -# Parameters -BASENAME="`basename $0`" -PROGRAM="$1" -CACHE="$HOME/.local/share/weather" - -# Load config -source $HOME/.custom/wttr.in.conf || exit 1 - -# weather-forecast service query -function weather_forecast_query { - # Make sure everything we need exists - mkdir -p $CACHE - touch $CACHE/weather-forecast.cur $CACHE/weather-forecast.prev - - # Save the previous forecast - cp $CACHE/weather-forecast.cur $CACHE/weather-forecast.prev - curl wttr.in/$LOCATION > $CACHE/weather-forecast.cur 2> /dev/null - - # Test if current forecast is empty, meaning - # that we're probably ofline. In that case - # we provide the previous output. - if [ ! -s "$CACHE/weather-forecast.cur" ]; then - cp $CACHE/weather-forecast.prev $CACHE/weather-forecast.cur - fi - - # Display output - cat $CACHE/weather-forecast.cur -} - -# Main -weather_forecast_query diff --git a/weather-query b/weather-query deleted file mode 100755 index f834415..0000000 --- a/weather-query +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# Simple wrapper around brweather -# - -# Parameters -BASENAME="`basename $0`" -PROGRAM="$1" -CACHE="$HOME/.local/share/weather" - -# Command line args -shift - -# Weather service query -function weather_query { - # Make sure everything we need exists - mkdir -p $CACHE - touch $CACHE/weather.cur $CACHE/weather.prev - - # Save the previous forecast - cp $CACHE/weather.cur $CACHE/weather.prev - weather $* > $CACHE/weather.cur 2> /dev/null - - # Test if current forecast is empty, meaning - # that we're probably ofline. In that case - # we provide the previous output. - if [ ! -s "$CACHE/weather.cur" ]; then - cp $CACHE/weather.prev $CACHE/weather.cur - fi - - # Display output - cat $CACHE/weather.cur -} - -# Main -if [ "$PROGRAM" == 'brweather' ]; then - brweather $* | grep -v 'Erro.' -else - weather_query -fi @@ -1,16 +0,0 @@ -#!/bin/bash -# -# Wifi initializer -# - -#DEVICE="ath0" -DEVICE="wlan0" - -if [ ! -z "$1" ]; then - read -sp "Enter the WPA passphrase: " PASS - echo "" - wpa_passphrase $1 $PASS -elif [ -f "wpa_supplicant.conf" ]; then - sudo wpa_supplicant -B -Dwext -i$DEVICE -cwpa_supplicant.conf - sudo dhclient $DEVICE -fi diff --git a/xclip-ssh b/xclip-ssh deleted file mode 100755 index 46c94b3..0000000 --- a/xclip-ssh +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env bash -# -# Intersystem communication via clipboard over SSH! -# Transmits data using the clipboard via SSH session. -# -# Description: -# -# xclip-ssh does what the same says - xclip over SSH. -# Works even with a remote host in a .onion service! -# And even between virtual machines! -# -# Works around the following PoC: -# -# ssh -X <server> # log in the remote system -# DISPLAY=:0 xclip -o # extracts remote's clipboard -# -# Usage: -# -# xclip-ssh send <server> [stdin|data] -# xclip-ssh receive <server> [stdout|xclip] -# -# Examples: -# -# cat /path/to/file | xclip-ssh send server -# xclip-ssh send server "some text" -# xclip-ssh receive server stdout > saved.txt - -# Parameters -BASENAME="`basename $0`" -ACTION="$1" -SERVER="$2" -STORE="$3" - -# Display usage -function xclip_ssh_usage { - echo "usage: $BASENAME <send|receive> <server> [data]" - exit 1 -} - -# Send data -function xclip_ssh_send { - if [ -z "$STORE" ]; then - STORE="xclip" - fi - - if [ "$STORE" == "xclip" ]; then - CONTENT="`xclip -o`" - elif [ "$STORE" == "stdin" ]; then - mapfile -t CONTENT - #printf '%s\n' "${CONTENT[@]}" - else - shift 2 - CONTENT="$*" - fi - - # See https://askubuntu.com/questions/804095/how-do-i-disable-the-message-of-the-day-motd-on-ubuntu-14-04 - ssh -q -X $SERVER bash <<EOF - ##### BEGIN REMOTE SCRIPT ##### - if ! which xclip &> /dev/null; then - echo "$BASENAME: missing xclip in the remote server" - else - echo ${CONTENT[@]} | DISPLAY=:0 xclip - fi - ##### END REMOTE SCRIPT ####### -EOF -} - -# Receive data helper -function xclip_ssh_helper { - ssh -q -X $SERVER bash <<EOF - ##### BEGIN REMOTE SCRIPT ##### - if ! which xclip &> /dev/null; then - echo "$BASENAME: missing xclip in the remote server" - else - DISPLAY=:0 xclip -o - fi - ##### END REMOTE SCRIPT ####### -EOF -} - -# Receive data -function xclip_ssh_receive { - if [ -z "$STORE" ]; then - STORE="xclip" - fi - - if [ "$STORE" == "stdout" ]; then - xclip_ssh_helper - echo "" - else - xclip_ssh_helper | xclip -i - fi -} - -# Check -if [ -z "$2" ]; then - xclip_ssh_usage -elif [ "$ACTION" != "send" ] && [ "$ACTION" != "receive" ]; then - xclip_ssh_usage -elif ! which xclip &> /dev/null; then - echo "$BASENAME: please install xclip" - exit 1 -fi - -# Dispatch -xclip_ssh_$ACTION $* diff --git a/xdg-add b/xdg-add deleted file mode 100755 index d572ba9..0000000 --- a/xdg-add +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# -# A xdg-mime shortcut. -# - -# Parameters -APP="$1" -FILETYPE="$2" - -# Check if second param is a file -if [ -e "$FILETYPE" ]; then - FILETYPE="`xdg-mime query filetype $FILETYPE`" -fi - -# Make association -xdg-mime default ${APP}.desktop $FILETYPE diff --git a/youtube-player b/youtube-player deleted file mode 100755 index 46b8dd5..0000000 --- a/youtube-player +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# Youtube player from the command line -# https://unix.stackexchange.com/questions/160212/watch-youtube-videos-in-terminal -# - -# Parameters -BASENAME="`basename $0`" -URL="$1" - -# Check -if [ -z "$1" ]; then - echo "usage: $BASENAME <url>" - exit 1 -fi - -# Run -youtube-dl $URL -o - | mplayer -vo aa -monitorpixelaspect 0.5 - |