You are not logged in.

#1 2016-06-23 19:51:42

KrunchTime
Member
Registered: 2015-09-29
Posts: 857

[SOLVED] How to Call bl-lock from New bl-exit?

bunsen-utilities has been updated and bl-exit has changed significantly.  I was able to change prior versions of bl-exit by adding

call("bl-lock")

under the

def suspend():

function(?).

So, under the new version of bl-exit, I've tried the following under the

def suspend_action(self, button):

function(?):

call("bl-lock")
--and--
self.call("bl-lock")

neither of which works.  So, how can I incorporate bl-lock in the new bl-exit script?

Last edited by KrunchTime (2016-06-24 19:26:19)

Offline

#2 2016-06-23 20:07:25

damo
....moderator....
Registered: 2015-08-20
Posts: 5,203

Re: [SOLVED] How to Call bl-lock from New bl-exit?

Have you tried running bl-exit in a terminal, and seeing what error messages may be produced? For example, with 'call("bl-lock")' and clicking "Suspend", I get:

$ bl-exit
** Message: light-locker is not running

Last edited by damo (2016-06-23 20:10:15)


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Online

#3 2016-06-23 20:08:30

KrunchTime
Member
Registered: 2015-09-29
Posts: 857

Re: [SOLVED] How to Call bl-lock from New bl-exit?

No, I have not.

Edit:  OK, I've ran bl-exit from the command line and I'm getting the following errors, which are basically programming errors.  I somewhat understand the errors, but not sure how to correct as I'm not a Python programmer.

with call("bl-exit"):

Traceback (most recent call last):
  File "/usr/bin/bl-exit", line 318, in suspend_action
    call("bl-lock")
NameError: global name 'call' is not defined

with self.call("bl-exit"):

Traceback (most recent call last):
  File "/usr/bin/bl-exit", line 318, in suspend_action
    self.call("bl-lock")
AttributeError: 'BlexitWindow' object has no attribute 'call'

Last edited by KrunchTime (2016-06-23 20:16:59)

Offline

#4 2016-06-23 20:11:09

damo
....moderator....
Registered: 2015-08-20
Posts: 5,203

Re: [SOLVED] How to Call bl-lock from New bl-exit?

You can also do

bl-exit --suspend

Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Online

#5 2016-06-24 10:29:19

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: [SOLVED] How to Call bl-lock from New bl-exit?

@KrunchTime,

Here is a patch that does what you requested.
Untested though.
Let me know if it does not work for you.

 /h/m/tmp diff -u /usr/bin/bl-exit ./bl-exit.new
--- /usr/bin/bl-exit	2016-06-23 14:02:00.000000000 +0200
+++ ./bl-exit.new	2016-06-24 12:04:09.894717799 +0200
@@ -53,6 +53,11 @@
 
     def do_action(self, action):
         print("do_action: {}".format(action), file=sys.stderr)
+        if action == "Suspend":
+            try:
+                subprocess.call("bl-lock")
+            except OSError as e:
+                self.on_error(str(e))
         self.send_dbus(action)
 
     def send_dbus(self, method):
 

Edit:
Don't change the indentation. Indentation has meaning in python.

Offline

#6 2016-06-24 19:25:58

KrunchTime
Member
Registered: 2015-09-29
Posts: 857

Re: [SOLVED] How to Call bl-lock from New bl-exit?

@xaos52:  Thank you very much.  It works like a charm.  For the benefit of others who may want to do the same, I placed the patch under the BlexitBase class as follows:

    def do_action(self, action):
        print("do_action: {}".format(action), file=sys.stderr)
        self.send_dbus(action)
        
    def do_action(self, action):
        print("do_action: {}".format(action), file=sys.stderr)
        if action == "Suspend":
            try:
                subprocess.call("bl-lock")
            except OSError as e:
                self.on_error(str(e))
        self.send_dbus(action)

    def send_dbus(self, method):
        try:
            if self.dbus_iface is None:
                self.setup_dbus_connection()
            if method[:3] == "Can":
                command = "self.dbus_iface.{}()".format(method)
            else:
                command = "self.dbus_iface.{}(['True'])".format(method)
            response = eval(command)
            return str(response)
        except dbus.DBusException as e:
            self.on_error(str(e))

Last edited by KrunchTime (2016-06-24 19:29:11)

Offline

Board footer

Powered by FluxBB