Merge branch 'master' of /git/dotfiles/scripts
authorJulien Valroff <julien@kirya.net>
Mon, 15 Feb 2016 12:36:19 +0000 (13:36 +0100)
committerJulien Valroff <julien@kirya.net>
Mon, 15 Feb 2016 12:36:19 +0000 (13:36 +0100)
autosync-xdg-launcher.sh [deleted file]
deb.li [deleted file]
extract-attachment.pl [new file with mode: 0755]
gcal-notify [deleted file]
mount-shares.sh [deleted file]
touchpad [deleted file]

diff --git a/autosync-xdg-launcher.sh b/autosync-xdg-launcher.sh
deleted file mode 100755 (executable)
index b429f6d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-# This simple script will start autosync.py daemons for all configs found in $XDG_CONF_HOME/autosync/,
-# stopping any existing daemons with that config first.
-conf=${XDG_CONF_HOME:-$HOME/.config}/autosync
-data=${XDG_DATA_HOME:-$HOME/.local/share}/autosync
-mkdir -p $data/{log,pid}
-
-# Automatically delete logs older than 5 days
-find $data/log/ -name '*.log' -ctime +5 -delete
-
-# Only starts configuration files ending with .conf
-# which makes it easy to disable some
-for i in $conf/*.conf
-do
-    pkill -u $(whoami) -f "python.*dvcs-autosync .*autosync/$(basename $i)"
-    dvcs-autosync $i &> $data/log/$(basename $i).$(date '+%F-%T').log &
-done
diff --git a/deb.li b/deb.li
deleted file mode 100755 (executable)
index 3b5971e..0000000
--- a/deb.li
+++ /dev/null
@@ -1,3 +0,0 @@
-# call me 'deb.li' and use me as 'deb.li http://some/long/url', stdout is a cut-and-paste friendly URL
-hash=$(ssh alioth.debian.org ~bzed/godebian-client/add_url \"$@\")
-echo "http://deb.li/$hash"
diff --git a/extract-attachment.pl b/extract-attachment.pl
new file mode 100755 (executable)
index 0000000..0bb63f9
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $boundary="none";
+my $type="none";
+my $fname="none";
+my $location="nowhere";
+
+foreach my $line (<STDIN>) {
+
+   chomp;
+
+   if ($line =~ /^Content-type:\s.*\sboundary=.*$/i) {
+
+        $line =~ s/\"//g;
+        ($boundary) = $line=~ m/.*=(.*)$/;
+        next;
+
+   } elsif (($line =~ /$boundary/) && ($location =~ /nowhere/)){
+        $location="header";
+        next;
+   }
+
+   if ($location =~ /header/) {
+        if ($line =~ /^Content-type:\s.*;\s.*$/i) {
+
+                ($type) = $line=~ /^Content-type:\s(.*);\s.*$/i;
+
+        } elsif ($line =~ /^Content-Disposition:\sattachment;\s.*$/i) {
+
+                $line =~ s/\"//g;
+                ($fname) = $line=~ /^Content-Disposition:\sattachment;\sfilename=(.*)$/i;
+
+        } else {
+                next unless ($line =~ /^$/) ;
+                if ( not $fname =~ /none/) {
+                        $location="body";
+                        open(ATT, ">.".$fname.".b64") || die "Could not open file\n";
+                        print ATT "begin-base64 0644 ". $fname ."\n";
+                }else {
+                        $location="nowhere";
+                }
+        }
+
+  } elsif ($location =~ /body/) {
+
+        if ($line =~ /$boundary/){
+                print ATT "====\n";
+                close (ATT);
+                my @args = ("uudecode", ".".$fname.".b64");
+                system(@args) == 0
+                         or die "system @args failed: $?" ;
+                print $fname."\n";
+
+                $fname="none";
+                $type="none";
+
+        if (not $line =~ /$boundary--/){
+                $location="header";
+        }
+
+        } else {
+                print ATT $line;
+        }
+
+  }
+
+}
diff --git a/gcal-notify b/gcal-notify
deleted file mode 100755 (executable)
index 6fed732..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/python
-"""
-Usage: gcal-notify [OPTION]
-
-  -h, --help        displays this help
-  -n, --new         create a new account in the default GNOME keyring
-  -d, --daemonize   check new events on a regular basis (default 10 minutes)
-
-When called without option, gcal-notify will check the events once only.
-
-Send a notification when an event with an alert occurs on the default Google Calendar.
-Accounts information are saved within the default GNOME keyring.
-
-Most code and idea from: http://julien.danjou.info/blog/2012/google-calendar-pynotify
-"""
-
-import sys
-import gtk
-import datetime
-import time
-import getpass
-import pynotify
-import gdata.calendar.service
-import gnomekeyring as gkey
-import string
-import getopt
-
-gkey.get_default_keyring_sync()
-pynotify.init(sys.argv[0])
-
-def get_credentials():
-    """ Retrieve credentials from the default GNOME Keyring """
-    attrs = {"server": "google", "protocol": "googlecal"}
-    items = gkey.find_items_sync(gkey.ITEM_NETWORK_PASSWORD, attrs)
-    return items[0].attributes["user"], items[0].secret
-
-def set_password():
-    """ Add new account into the default GNOME Keyring """
-    username = raw_input("Username: ")
-    password = getpass.getpass(prompt="Password: ")
-    print
-
-    attrs = {
-        "user": username,
-        "server": "google",
-        "protocol": "googlecal" ,
-    }
-    gkey.item_create_sync(gkey.get_default_keyring_sync(),
-            gkey.ITEM_NETWORK_PASSWORD, "Google", attrs, password, True)
-    
-    print ("User added.")
-
-def daemonize():
-    """ Run a loop and check events every 10 minutes """
-    while True:
-        process()
-        time.sleep(600)
-
-
-def process():
-    """ Retrieve events and display a notification """
-    # Then, we need to import gdata Calendar API and connect to the calendar.
-    calendar_service = gdata.calendar.service.CalendarService()
-    (calendar_service.email, calendar_service.password) = get_credentials()
-    calendar_service.ProgrammaticLogin()
-
-    # Request the events from the default calendar.
-    feed = calendar_service.GetCalendarEventFeed()
-
-    # Now we can iterate over feed and do various checks.
-    for event in feed.entry:
-        # If the event status is not confirmed, go to the next event.
-        if event.event_status.value != "CONFIRMED":
-            continue
-        # Now iterate over all the event dates (usually it has one)
-        for when in event.when:
-            # Parse start and end time
-            try:
-                start_time = datetime.datetime.strptime(when.start_time.split(".")[0], "%Y-%m-%dT%H:%M:%S")
-                end_time = datetime.datetime.strptime(when.end_time.split(".")[0], "%Y-%m-%dT%H:%M:%S")
-            except ValueError:
-                # ValueError happens on parsing error. Parsing errors
-                # usually happen for "all day" events since they have
-                # not time, but we do not care about this events.
-                continue
-            now = datetime.datetime.now()
-            # Check that the event hasn't already ended
-            if end_time > now:
-                # Check each alert
-                for reminder in when.reminder:
-                    # We handle only reminders with method "alert"
-                    # and whose start time minus the reminder delay has passed
-                    if reminder.method == "alert" \
-                            and start_time - datetime.timedelta(0, 60 * int(reminder.minutes)) < now:
-                        # Build the notification
-                        notification = pynotify.Notification(summary=event.title.text,
-                                message="\n".join(filter(None, (event.content.text, "<a href='https://www.google.com/calendar/render'>Google Calendar</a>"))))
-                        # Set an icon from the GTK+ stock icons
-                        notification.set_icon_from_pixbuf(gtk.Label().render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_LARGE_TOOLBAR))
-                        notification.set_timeout(0)
-                        # Show the notification
-                        notification.show()
-
-def main():
-    # parse command line options
-    try:
-        opts, args = getopt.getopt(sys.argv[1:], "hnd", ["help", "new", "daemonize"])
-    except getopt.error, msg:
-        print msg
-        print "for help use --help"
-        sys.exit(2)
-    # process options
-    for o, a in opts:
-        if o in ("-h", "--help"):
-            print __doc__
-            sys.exit(0)
-        elif o in ("-n", "--new"):
-            set_password()
-            sys.exit()
-        elif o in ("-d", "--daemonize"):
-            daemonize()
-    # no option, no argument
-    process()
-
-if __name__ == "__main__":
-    main()
diff --git a/mount-shares.sh b/mount-shares.sh
deleted file mode 100755 (executable)
index 820728b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-ping -c1 -q freebox-server.local && gvfs-mount ftp://freebox-server.local/
diff --git a/touchpad b/touchpad
deleted file mode 100755 (executable)
index 019fac5..0000000
--- a/touchpad
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-if grep -iq 'TouchPad' /proc/bus/input/devices; then
-    synclient VertEdgeScroll=1 &
-    synclient VertTwoFingerScroll=1 &
-    synclient TapButton1=1 &
-    syndaemon -i0.2 -d &
-fi
-if grep -q 'ETPS/2 Elantech Touchpad' /proc/bus/input/devices; then
-    synclient MinSpeed=0 &
-    synclient MaxSpeed=2.5 &
-    synclient PalmDetect=1 &
-    synclient AccelFactor=0.15 &
-    synclient VertScrollDelta=15 &
-fi