From: Oleg Broytman Date: Tue, 21 Jan 2014 20:15:53 +0000 (+0400) Subject: Initial commit X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=36e36baa9bea6f1f8e579f584cae7d3f91d9ae31;p=IM.git Initial commit --- 36e36baa9bea6f1f8e579f584cae7d3f91d9ae31 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00b0340 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +im-away encoding=koi8-r +im-busy encoding=koi8-r +im-eat encoding=koi8-r +im-invisible encoding=koi8-r +im-movie encoding=koi8-r +im-na encoding=koi8-r +im-offline encoding=koi8-r +im-online encoding=koi8-r +im-phone encoding=koi8-r +im-reading encoding=koi8-r +im-tea encoding=koi8-r diff --git a/agent.mail.ru-status b/agent.mail.ru-status new file mode 100755 index 0000000..458c279 --- /dev/null +++ b/agent.mail.ru-status @@ -0,0 +1,10 @@ +#! /bin/sh + +if [ "$1" ]; then + ID="$1" +else + echo "Usage: $0 email" >&2 + exit 1 +fi + +wget -Y off -O - -q "http://status.mail.ru/?$ID" | xli stdin diff --git a/icq-status b/icq-status new file mode 100755 index 0000000..8d034dc --- /dev/null +++ b/icq-status @@ -0,0 +1,16 @@ +#! /bin/sh + +if [ "$1" ]; then + uin="$1" +else + echo "Usage: $0 uin" >&2 + exit 1 +fi + +wget -Y off -O - -q "http://status.icq.com/online.gif?icq=$uin&img=21" | xli stdin +#wget -Y off -O - -q "http://status.icq.com/online.gif?web=$uin&img=1" | xli stdin +#wget -Y off -O - -q "http://online.mirabilis.com/scripts/online.dll?icq=$uin&img=5" | xli stdin + +# online0.gif - Offline +# online1.gif - Online +# online2.gif - Unknown diff --git a/icq-status.py b/icq-status.py new file mode 100755 index 0000000..27443cf --- /dev/null +++ b/icq-status.py @@ -0,0 +1,44 @@ +#! /usr/bin/env python + +import sys + +try: + uin = sys.argv[1] +except IndexError: + sys.exit("Usage: %s uin" % sys.argv[0]) + +url = "http://status.icq.com/online.gif?icq=%s&img=1" % uin + +import socket +socket.setdefaulttimeout(30) + +import urllib +protocol, request = urllib.splittype(url) +host, path = urllib.splithost(request) +host, port = urllib.splitport(host) +path, tag = urllib.splittag(path) + +import httplib +server = httplib.HTTP(host, port) + +server.putrequest("HEAD", path) +server.putheader("Host", host) +server.endheaders() + +status, reason, msg = server.getreply() +if status == 302: + online = msg["Location"] +else: + print >>sys.stderr, status, reason, msg + sys.exit(1) + +# Classify online status +if online == "/1/online0.gif": + print "Offline" +elif online == "/1/online1.gif": + print "Online" +elif online == "/1/online2.gif": + print "Unknown/invisible" +else: + print >>sys.stderr, "Unknown status", online + sys.exit(1) diff --git a/im-away b/im-away new file mode 100755 index 0000000..953864a --- /dev/null +++ b/im-away @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status away "Away / ïÔÏÛ£Ì" diff --git a/im-busy b/im-busy new file mode 100755 index 0000000..6c87a3d --- /dev/null +++ b/im-busy @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status dnd "Working / òÁÂÏÔÁÀ" diff --git a/im-eat b/im-eat new file mode 100755 index 0000000..8ce3794 --- /dev/null +++ b/im-eat @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status away "Eating / õÛ£Ì ÐÏÅÓÔØ" diff --git a/im-invisible b/im-invisible new file mode 100755 index 0000000..39a0ccd --- /dev/null +++ b/im-invisible @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status invisible "Bye! ðÏËÁ!" diff --git a/im-movie b/im-movie new file mode 100755 index 0000000..07dfc4f --- /dev/null +++ b/im-movie @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status away "Watching a movie / óÍÏÔÒÀ ËÉÎÏ" diff --git a/im-na b/im-na new file mode 100755 index 0000000..27e6695 --- /dev/null +++ b/im-na @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status xa "I'm not available / õÛ£Ì" diff --git a/im-offline b/im-offline new file mode 100755 index 0000000..c877662 --- /dev/null +++ b/im-offline @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status offline "Offline / îÅ × ÓÅÔÉ" diff --git a/im-online b/im-online new file mode 100755 index 0000000..4e77ecd --- /dev/null +++ b/im-online @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status online "Available / ñ ÚÄÅÓØ" diff --git a/im-phone b/im-phone new file mode 100755 index 0000000..d03aed1 --- /dev/null +++ b/im-phone @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status dnd "I'm on the phone / çÏ×ÏÒÀ ÐÏ ÔÅÌÅÆÏÎÕ" diff --git a/im-reading b/im-reading new file mode 100755 index 0000000..93bdc50 --- /dev/null +++ b/im-reading @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status away "Reading / þÉÔÁÀ" diff --git a/im-status.sh b/im-status.sh new file mode 100755 index 0000000..75f43b3 --- /dev/null +++ b/im-status.sh @@ -0,0 +1,43 @@ +#! /bin/sh + +case "$2" in + online) + status="available" + skype_status="online" + ;; + + busy|dnd) + status="unavailable" + skype_status="dnd" + ;; + + xa) + status="extended_away" + skype_status="na" + ;; + + *) status="$2" + skype_status="$2" + ;; +esac + +case "$LC_CTYPE" in + *KOI8-R) + title="$3" + status_msg="`echo \"$3\" | iconv -t utf-8`" + ;; + + *) + title="`echo \"$3\" | iconv -f koi8-r`" + status_msg="$title" + ;; +esac + +if [ "`gajim-remote check_gajim_running 2>/dev/null`" = True ]; then + gajim-remote change_status "$2" "$3" +else + purple-remote "setstatus?status=$status&message=$status_msg" +fi && +n900-status-wifi "$1" && +xtitle "$1" "$2" "$title" && +exec skype_status_mood.py "$skype_status" "$3" >/dev/null diff --git a/im-tea b/im-tea new file mode 100755 index 0000000..672c78a --- /dev/null +++ b/im-tea @@ -0,0 +1,4 @@ +#! /bin/sh + +status="`basename \"$0\" | sed s/^im-//`" && +exec im-status.sh $status away "I'm enjoying a cup of tea / ðØÀ ÞÁÊ" diff --git a/n900-status-wifi b/n900-status-wifi new file mode 100755 index 0000000..07f39bf --- /dev/null +++ b/n900-status-wifi @@ -0,0 +1,5 @@ +#! /bin/sh + +[ -S "$HOME"/.ssh/controls/root@n900-wifi:22 ] && + ssh -4 root@n900-wifi "exec run-standalone.sh exec /usr/local/bin/im-$1" +exit 0 diff --git a/skype-status b/skype-status new file mode 100755 index 0000000..ff0b2d3 --- /dev/null +++ b/skype-status @@ -0,0 +1,11 @@ +#! /bin/sh + +if [ "$1" ]; then + skype_name="$1" +else + echo "Usage: $0 skype_name" >&2 + exit 1 +fi + +wget -Y off -O - -q "http://mystatus.skype.com/smallicon/$skype_name" | xli stdin +wget -Y off -O - -q "http://mystatus.skype.com/bigclassic/$skype_name" | xli stdin diff --git a/skype_status_mood.py b/skype_status_mood.py new file mode 100755 index 0000000..2331c51 --- /dev/null +++ b/skype_status_mood.py @@ -0,0 +1,62 @@ +#!/usr/bin/python + +# Based on https://blog.arrington.me/2012/change-your-skype-mood-text-in-linux-with-python/ +# script to change Skype status, usage: skype_status_mood.py new_status [mood_text] + +# Copyright (c) 2010 +# Matthew M. Boedicker +# +# In 2013 Oleg Broytman added ability to get/set mood text + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Valid statuses at https://developer.skype.com/Docs/ApiDoc/GET_USERSTATUS + +import dbus +import sys + +bus = dbus.SessionBus() + +proxy = bus.get_object('com.Skype.API', '/com/Skype') + +commands = [ + 'NAME skype_status_mood.py', + 'PROTOCOL 2' +] + +stdin_encoding = sys.stdin.encoding +if stdin_encoding is None: + stdin_encoding = 'utf-8' + +if len(sys.argv) >= 4: + sys.exit("Usage: %s [new_status [mood_text]]" % sys.argv[0]) +if len(sys.argv) >= 3: + commands.append(u'SET PROFILE MOOD_TEXT %s' % sys.argv[2].decode(stdin_encoding)) +if len(sys.argv) >= 2: + commands.append('SET USERSTATUS %s' % sys.argv[1]) +else: + commands.append('GET USERSTATUS') + commands.append('GET PROFILE MOOD_TEXT') + +stdout_encoding = sys.stdout.encoding +if stdout_encoding is None: + stdout_encoding = 'utf-8' + +for command in commands: + print proxy.Invoke(command).encode(stdout_encoding)