]> git.phdru.name Git - IM.git/commitdiff
Initial commit
authorOleg Broytman <phd@phdru.name>
Tue, 21 Jan 2014 20:15:53 +0000 (00:15 +0400)
committerOleg Broytman <phd@phdru.name>
Tue, 21 Jan 2014 20:15:53 +0000 (00:15 +0400)
19 files changed:
.gitattributes [new file with mode: 0644]
agent.mail.ru-status [new file with mode: 0755]
icq-status [new file with mode: 0755]
icq-status.py [new file with mode: 0755]
im-away [new file with mode: 0755]
im-busy [new file with mode: 0755]
im-eat [new file with mode: 0755]
im-invisible [new file with mode: 0755]
im-movie [new file with mode: 0755]
im-na [new file with mode: 0755]
im-offline [new file with mode: 0755]
im-online [new file with mode: 0755]
im-phone [new file with mode: 0755]
im-reading [new file with mode: 0755]
im-status.sh [new file with mode: 0755]
im-tea [new file with mode: 0755]
n900-status-wifi [new file with mode: 0755]
skype-status [new file with mode: 0755]
skype_status_mood.py [new file with mode: 0755]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..00b0340
--- /dev/null
@@ -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 (executable)
index 0000000..458c279
--- /dev/null
@@ -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 (executable)
index 0000000..8d034dc
--- /dev/null
@@ -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 (executable)
index 0000000..27443cf
--- /dev/null
@@ -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 (executable)
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 (executable)
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 (executable)
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 (executable)
index 0000000..39a0ccd
--- /dev/null
@@ -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 (executable)
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 (executable)
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 (executable)
index 0000000..c877662
--- /dev/null
@@ -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 (executable)
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 (executable)
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 (executable)
index 0000000..93bdc50
--- /dev/null
@@ -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 (executable)
index 0000000..75f43b3
--- /dev/null
@@ -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 (executable)
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 (executable)
index 0000000..07f39bf
--- /dev/null
@@ -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 (executable)
index 0000000..ff0b2d3
--- /dev/null
@@ -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 (executable)
index 0000000..2331c51
--- /dev/null
@@ -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 <matthewm@boedicker.org>
+#
+# In 2013 Oleg Broytman <phd@phdru.name> 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)