maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   SOLVED: Sign in/out Skype (set availability Online/Offline) with cron (https://talk.maemo.org/showthread.php?t=55686)

bristoldave 2010-06-09 20:10

SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
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.

bristoldave 2010-06-10 10:35

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
Solved - see above

ffarber 2010-07-20 01:54

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
Awesome!! Thanks so much. I did have to fix a few minor indentation errors. No big deal.

Fred

what 2010-08-05 22:51

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
Thanks a lot, great posting!
But beware, this will bring offline/online all IM accounts, not only Skype.

xomm 2010-08-05 22:59

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
Thread moved to Applications.

fiskfan 2010-08-12 13:28

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
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 2011-01-21 20:09

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
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

hillbicks 2011-05-01 15:41

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
Quote:

Originally Posted by Schturman (Post 925656)
.....
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?

Zas 2011-05-01 16:01

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
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.

Schturman 2011-05-05 10:37

Re: SOLVED: Sign in/out Skype (set availability Online/Offline) with cron
 
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...

Quote:

Originally Posted by Zas (Post 998338)
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"...


All times are GMT. The time now is 19:29.

vBulletin® Version 3.8.8