]> git.phdru.name Git - IM.git/blob - skype_status_mood.py
Feat(im-status.sh): Check if the programs are running
[IM.git] / skype_status_mood.py
1 #!/usr/bin/python
2
3 # Based on https://blog.arrington.me/2012/change-your-skype-mood-text-in-linux-with-python/
4 # script to change Skype status, usage: skype_status_mood.py new_status [mood_text]
5
6 # Copyright (c) 2010
7 # Matthew M. Boedicker <matthewm@boedicker.org>
8 #
9 # In 2013 Oleg Broytman <phd@phdru.name> added ability to get/set mood text
10
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to deal
13 # in the Software without restriction, including without limitation the rights
14 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
17
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
20
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 # THE SOFTWARE.
28
29 # Valid statuses at https://developer.skype.com/Docs/ApiDoc/GET_USERSTATUS
30
31 import dbus
32 import sys
33
34 bus = dbus.SessionBus()
35
36 proxy = bus.get_object('com.Skype.API', '/com/Skype')
37
38 commands = [
39     'NAME skype_status_mood.py',
40     'PROTOCOL 2'
41 ]
42
43 stdin_encoding = sys.stdin.encoding
44 if stdin_encoding is None:
45     stdin_encoding = 'utf-8'
46
47 if len(sys.argv) >= 4:
48     sys.exit("Usage: %s [new_status [mood_text]]" % sys.argv[0])
49 if len(sys.argv) >= 3:
50     commands.append(u'SET PROFILE MOOD_TEXT %s' % sys.argv[2].decode(stdin_encoding))
51 if len(sys.argv) >= 2:
52     commands.append('SET USERSTATUS %s' % sys.argv[1])
53 else:
54     commands.append('GET USERSTATUS')
55     commands.append('GET PROFILE MOOD_TEXT')
56
57 stdout_encoding = sys.stdout.encoding
58 if stdout_encoding is None:
59     stdout_encoding = 'utf-8'
60
61 for command in commands:
62     print proxy.Invoke(command).encode(stdout_encoding)