Active Topics

 



Notices


Reply
Thread Tools
Posts: 51 | Thanked: 21 times | Joined on May 2010
#1
As per post title really, does anyone know the shell commands to go online/offline with Skype etc so I can cron it?

Thanks.

EDIT:

I have managed to solve this with a bit of digging on the forums and adapting of scripts. The first script I created called "skype-online" is here:

Code:
#!/usr/bin/env python

import dbus
import gobject

#NAMES
TP_ACCT_MGR = 'org.freedesktop.Telepathy.AccountManager'
TP_ACCT = 'org.freedesktop.Telepathy.Account'
DBUS_PROPS = 'org.freedesktop.DBus.Properties'

sessbus = dbus.SessionBus()
am_obj = sessbus.get_object(TP_ACCT_MGR,
                            '/org/freedesktop/Telepathy/AccountManager')
am_props = dbus.Interface(am_obj, DBUS_PROPS)

    accounts = am_props.Get(TP_ACCT_MGR,
                            "ValidAccounts")
    for path in accounts:
        if ("/org/freedesktop/Telepathy/Account/ring/tel/ring" == path):
            continue
        acct_obj = sessbus.get_object(TP_ACCT_MGR, path)
        acct_props = dbus.Interface(acct_obj, DBUS_PROPS)

        acct_props.Set(TP_ACCT,
                           "RequestedPresence",
                           dbus.Struct((dbus.UInt32(2),
                                        dbus.String(u"available"),
                                        dbus.String(u"") )) )
        acct_props.Set(TP_ACCT,
                           "ConnectAutomatically",
                           dbus.Boolean(True))
and skype-offline:

Code:
#!/usr/bin/env python

import dbus
import gobject

#NAMES
TP_ACCT_MGR = 'org.freedesktop.Telepathy.AccountManager'
TP_ACCT = 'org.freedesktop.Telepathy.Account'
DBUS_PROPS = 'org.freedesktop.DBus.Properties'

sessbus = dbus.SessionBus()
am_obj = sessbus.get_object(TP_ACCT_MGR,
                            '/org/freedesktop/Telepathy/AccountManager')
am_props = dbus.Interface(am_obj, DBUS_PROPS)

    accounts = am_props.Get(TP_ACCT_MGR,
                            "ValidAccounts")
    for path in accounts:
        if ("/org/freedesktop/Telepathy/Account/ring/tel/ring" == path):
            continue
        acct_obj = sessbus.get_object(TP_ACCT_MGR, path)
        acct_props = dbus.Interface(acct_obj, DBUS_PROPS)

            acct_props.Set(TP_ACCT,
                           "RequestedPresence",
                           dbus.Struct((dbus.UInt32(1),
                                        dbus.String(u"offline"),
                                        dbus.String(u"") )) )
            acct_props.Set(TP_ACCT,
                           "ConnectAutomatically",
                           dbus.Boolean(False))
Then chmod +x both scripts. Then you can use alarmed or whatever to run these scripts to sign in and out.

Last edited by bristoldave; 2010-06-10 at 10:35.
 

The Following 11 Users Say Thank You to bristoldave For This Useful Post:
Posts: 51 | Thanked: 21 times | Joined on May 2010
#2
Solved - see above
 
Posts: 180 | Thanked: 41 times | Joined on Mar 2007 @ Maine
#3
Awesome!! Thanks so much. I did have to fix a few minor indentation errors. No big deal.

Fred
 
Posts: 1 | Thanked: 0 times | Joined on Aug 2010
#4
Thanks a lot, great posting!
But beware, this will bring offline/online all IM accounts, not only Skype.
 
xomm's Avatar
Posts: 609 | Thanked: 243 times | Joined on Jan 2010 @ Eastern USA
#5
Thread moved to Applications.
__________________
==In school once again. Free time limited to night, holidays and weekends.==
Hi! I'm Andy, a Maemo Greeter! I'm also a moderator of the Applications, Nokia N900, and Maemo 5/Fremantle forums.
Useful Links: Maemo Wiki Main Page, New users start here, Beginners' wiki page, Maemo5 101, Frequently Asked Questions (FAQ)
Also, pin yourself in the map! Maemo Map. Send me a PM (Private Message) if I leave you hanging on a problem (or if you need more help).
Owner of both a N800 and N900; Active community member since Jan 2010. You've been xommified! - My blog.
 
Posts: 1 | Thanked: 0 times | Joined on Aug 2010
#6
When i try to run this script, using /usr/bin/python2.5 /home/user/MyDocs/scripts/skypeonline.py i get this error:

Code:
Traceback (most recent call last):
  File "skypeonline.py", line 11, in <module>
    sessbus = dbus.SessionBus()
  File "/usr/lib/pymodules/python2.5/dbus/_dbus.py", line 219, in __new__
    mainloop=mainloop)
  File "/usr/lib/pymodules/python2.5/dbus/_dbus.py", line 108, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib/pymodules/python2.5/dbus/bus.py", line 125, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException
what am i doing wrong?
 
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#7
Hello
I have problem with trying to run this script... I think I don't know what I should to write...
I saved this script in my folder..
I did permission to this file (chmod +x)
I wrote in terminal: python /opt/Scripts/skape-online
and i got this message:
Code:
  File "/opt/Scripts/Skypeon.py", line 16
    accounts = am_props.Get(TP_ACCT_MGR,
    ^
IndentationError: unexpected indent
~ $
What I do is wrong ?
Thanks
 
Posts: 7 | Thanked: 2 times | Joined on Apr 2010
#8
Originally Posted by Schturman View Post
.....
What I do is wrong ?
Thanks
Working versions of both scripts:
online
Code:
#!/usr/bin/env python

import dbus
import gobject

#NAMES
TP_ACCT_MGR = 'org.freedesktop.Telepathy.AccountManager'
TP_ACCT = 'org.freedesktop.Telepathy.Account'
DBUS_PROPS = 'org.freedesktop.DBus.Properties'

sessbus = dbus.SessionBus()
am_obj = sessbus.get_object(TP_ACCT_MGR,
                            '/org/freedesktop/Telepathy/AccountManager')
am_props = dbus.Interface(am_obj, DBUS_PROPS)

accounts = am_props.Get(TP_ACCT_MGR,
                            "ValidAccounts")
for path in accounts:
        if ("/org/freedesktop/Telepathy/Account/ring/tel/ring" == path):
            continue
        acct_obj = sessbus.get_object(TP_ACCT_MGR, path)
        acct_props = dbus.Interface(acct_obj, DBUS_PROPS)

        acct_props.Set(TP_ACCT,
                           "RequestedPresence",
                           dbus.Struct((dbus.UInt32(2),
                                        dbus.String(u"available"),
                                        dbus.String(u"") )) )
        acct_props.Set(TP_ACCT,
                           "ConnectAutomatically",
                           dbus.Boolean(True))
offline
Code:
#!/usr/bin/env python

import dbus
import gobject

#NAMES
TP_ACCT_MGR = 'org.freedesktop.Telepathy.AccountManager'
TP_ACCT = 'org.freedesktop.Telepathy.Account'
DBUS_PROPS = 'org.freedesktop.DBus.Properties'

sessbus = dbus.SessionBus()
am_obj = sessbus.get_object(TP_ACCT_MGR,
                            '/org/freedesktop/Telepathy/AccountManager')
am_props = dbus.Interface(am_obj, DBUS_PROPS)

accounts = am_props.Get(TP_ACCT_MGR,
                            "ValidAccounts")
for path in accounts:
        if ("/org/freedesktop/Telepathy/Account/ring/tel/ring" == path):
            continue
        acct_obj = sessbus.get_object(TP_ACCT_MGR, path)
        acct_props = dbus.Interface(acct_obj, DBUS_PROPS)

        acct_props.Set(TP_ACCT,
                           "RequestedPresence",
                           dbus.Struct((dbus.UInt32(2),
                                        dbus.String(u"available"),
                                        dbus.String(u"") )) )
        acct_props.Set(TP_ACCT,
                           "ConnectAutomatically",
                           dbus.Boolean(True))
Unexpected indent. This line of code has more spaces at the start than the one before, but the one before is not the start of a subblock (e.g. if/while/for statement). All lines of code in a block must start with exactly the same string of whitespace

But I'd still like to know how to set the presence, or status of the IM accounts. Any ideas?

Last edited by hillbicks; 2011-05-01 at 15:43.
 
Zas's Avatar
Posts: 196 | Thanked: 113 times | Joined on Jun 2010 @ Finland
#9
If you install "libmissioncontrol-utils" you can set resence with:
Code:
mc-tool list | grep -v "ring/tel" | awk {'print "mc-tool request "$1" busy"'} | sh
Just replace "busy" with "offline" or "online".
If you don't want to set all accounts at once you can replace -v "ring/tel" (exclude -v) with "skype" or "ovi" or "gmail" etc. depending on the account settings.
 

The Following 3 Users Say Thank You to Zas For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#10
hillbicks, thanks this script is work, but "offline" still try to connect to internet... and "online" connect all my IM accounts..
I too want to know how to set MY presence of the IM accounts...

Originally Posted by Zas View Post
If you install "libmissioncontrol-utils" you can set resence with:
Code:
mc-tool list | grep -v "ring/tel" | awk {'print "mc-tool request "$1" busy"'} | sh
Just replace "busy" with "offline" or "online".
If you don't want to set all accounts at once you can replace -v "ring/tel" (exclude -v) with "skype" or "ovi" or "gmail" etc. depending on the account settings.
I installed this and your code working perfectly! Thanks..
But before I run this code, I need set my presence to "ofline", if I set "Online" all my accounts connecting automaticaly, when I connect to internet... The code not switching to one account, that I wrote in the code..
It's still a good, I only need to remember to switch "offline" before I run "desktop activity"...
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:07.