You are not logged in.

#76 2016-04-15 02:36:19

hhh
Meep!
Registered: 2015-09-17
Posts: 8,074
Website

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

xaos52 wrote:

I would appreciate it enormously if someone else could test the new version of the bl-exit script.
You can find an explanation on how to configure it hereThanks

Sorry I missed this, Doc. I'll give it a go ASAP.

ASAP=after speedy ale purchase

Offline

#77 2016-04-15 03:49:27

hhh
Meep!
Registered: 2015-09-17
Posts: 8,074
Website

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

@Rock Me Dr. Xaos, I put /bin/bl-exit in /usr/local/bin. No config, no change. Create ~/.config/bl-exit/bl-exitrc with your hibernate content, the button appears and my laptop hibernates (very glitchy and ugly on my 9 y.o. ThinkPad, but it works. Spotify picked up where it left off, sweet.)

Very slick, great work, and bravo. Take a bow for a very elegant solution.

-edit- Not all that glitchy or ugly, really, on second sight. I'm using it, it's great.

Offline

#78 2016-04-17 04:44:58

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,591
Website

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Quick test on a VM.

Default (no config) works fine.

Use  $HOME/.config/bl-exit/bl-exitrc

[hibernate]
show = maybe
onerror = visual

to add "Hibernate", and the button appears. Click it and the VM closes down.
Restart the VM and I get a black screen. No key or mouse action will get out of it, except using VirtualBox's R-Ctrl + Q to shutdown the VM. After that it comes back up OK but the session has been lost.

I guess that is an issue with Hibernate on that VM, possibly with LightDM or LightLocker.
At least I can say that bl-exit did not raise an error message when "Hibernate" was clicked.
However, Hibernate is not the sort of thing I ever expect to work anyway. (especially on a VM) roll

---

Possible unrelated suggestion: have bl-exit check /etc/bl-exit/bl-exitrc for a system-wide config file if there's no user file. We could ship a config that just spells out the hardcoded default settings, but would be a template for users to copy into ~/.config/bl-exit

Last edited by johnraff (2016-04-17 06:36:16)


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#79 2016-04-17 08:55:14

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

johnraff wrote:

Use  $HOME/.config/bl-exit/bl-exitrc

[hibernate]
show = maybe
onerror = visual

to add "Hibernate", and the button appears. Click it and the VM closes down.
Restart the VM and I get a black screen. No key or mouse action will get out of it, except using VirtualBox's R-Ctrl + Q to shutdown the VM. After that it comes back up OK but the session has been lost.

I have not configured my machine to use hibernation and if I use the "Hibernate" button then my machine shuts down.

I think this is the expected behaviour but I use btrfs so I can't make a swap file to enable hibernation to check this hmm


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#80 2016-04-17 16:12:49

Peregrino69
Member
Registered: 2016-03-11
Posts: 37

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Late to the game but...

Q1. Would you use that functionalty?

Next laptop I'm buying will very very likely to be running BL. Yes, I definitely would use it.

Q2. For 'Hibernate' to work, you need to set up adequate swap space.
       When the swap space is not sufficient to hibernate, choose one of the options below:
       1. I don't want to see the hibernate button.

... BUT I'd appreciate a dialog during installation "your swap space isn't sufficient for Hibernate, so the option will not be available".

Offline

#81 2016-04-18 06:32:19

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

So I tried this in Virtual box and it worked like a charm.  I created the ~/.config/bl-exit/bl-exitrc  file,  made it so that hibernate "always" displays. Ran the command file terminator, it shows up, saves the state, and upon restarting it via virtualbox, it re-loads the state. Some images for confirmation. After like 3 tries, I wasn't quick enough to get an image of the "Loading" image state, but trust me it worked big_smile

menu


saving


Great work Xaos!! Sort of makes me wish I knew python!

Last edited by Horizon_Brave (2016-04-18 06:32:56)


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#82 2016-04-21 00:42:08

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Hey Xaos will the new updated bl-exit script be added to the next official B.L release?  Assuming 8.5?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#83 2016-04-21 03:40:29

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,591
Website

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

^As soon as Dr. xaos declares it ready, it can go in a new version of bunsen-utilities, which anyone will get just by upgrading.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#84 2016-04-22 11:15:44

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

johnraff wrote:

to add "Hibernate", and the button appears. Click it and the VM closes down.
Restart the VM and I get a black screen. No key or mouse action will get out of it, except using VirtualBox's R-Ctrl + Q to shutdown the VM. After that it comes back up OK but the session has been lost.

Hibernate just works for me in a virtualbox guest.

Suspend is a little bit tricky:
Pressing suspend gives me the black screen.
It is as if the system then waits for a key press to wake up.
However, I did not find a way to send a key press to the guest, except by doing as you did:
RCtrl+Q and select shutdown.
Then I get the lightdm login screen and after entering my credentials I a back in the session where I left it. So that also works for me.

johnraff wrote:

Possible unrelated suggestion: have bl-exit check /etc/bl-exit/bl-exitrc for a system-wide config file if there's no user file. We could ship a config that just spells out the hardcoded default settings, but would be a template for users to copy into ~/.config/bl-exit

This is implemented now.
Latest development version of bl-exit can be found at my github repo in the master branch.

Head_on_a_Stick wrote:

I have not configured my machine to use hibernation and if I use the "Hibernate" button then my machine shuts down.

I would have expected an error message in this case, stating that the hibernate action is not available.
I am curious as to what the canHibernate script returns in your situation.
You can get the script from the github repo.
Run it without arguments:

canHibernate

That uses the dbus call I rely on to decide if hibernation is available or not.
Can you test that for me?

I have my complete hard disk reserved for btrfs, except for a swap partition. wink

 /h/me _ parted -l /dev/sda
[sudo] password for me: 
Model: ATA ST9500325AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size    Type     File system     Flags
 1      1049kB  496GB  496GB   primary  btrfs           boot
 2      496GB   500GB  4202MB  primary  linux-swap(v1)

Hibernation works for me.
And when I configure hibernation with 'show = maybe' abd disable swap with
'sudo swapoff -a', the hibernate button is greyed out.

When I configure it with 'show = always', the hibernate button is clickable, but if you click it, nothing happens except that an error message is written to $HOME/.xsession-errors.
When you configure it with 'onerror = visual' you get an error popup.

So, works as expected for me.

peregrino69 wrote:

... BUT I'd appreciate a dialog during installation "your swap space isn't sufficient for Hibernate, so the option will not be available".

We have discussed this and decided that the bl-welcome script is already overloaded.
You can always try to find enough support for your idea on the forum to make us change our mind.

However, I suppose the 'natural' flow of events for a user to enable hibernation is
1. Make sure it works on your system using 'sudo systemctl hibernate'
2. Change the bl-exit configuration to show the hibernate button always or only
   when it is available (show = maybe)

Horizon_Brave wrote:

Hey Xaos will the new updated bl-exit script be added to the next official B.L release?  Assuming 8.5?

8.5 is a Debian decision, completely independent from bl-exit.
See below for a time frame for including the new version in the BL repos.

johnraff wrote:

@xaos52, do you think the new bl-exit is ready to go in bunsen-utilities, so it can be in the iso, or would a post-release upgrade be OK? No backward compatibility issues, I guess?

I would prefer not to add it in hurry.
I am still finding bugs here and there, and small tweaks.
E.g. In the current version the screen with the buttons has a fixed size. With the new version there can be more or less buttons. The buttons sizes change with the number of buttons shown, which leads to buttons of different sizes. I have found a way to fix the button sizes, and make the window size variable.
You can test all this in the latest development version. See above for a link.

Also, I presume Unia would appreciate some time to review the new code.

I have also started work to migrate the script to python3 and gtk3 (see 'x52' branch)
That still is a 'Work In Progress' though.

A post-release upgrade would be OK, yes.
No backward compatibility issues either. Without configuration the script should work as the current one.

All in all lets say that a stable version will be available in a week at most from now.

Offline

#85 2016-04-28 08:43:52

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

I have been out with high temp all week.
Delivery of bl-exit will have to be postponed for a week.
Managed to make some small changes - visible in my github test repo - but needs some more testing.

Offline

#86 2016-04-28 09:32:56

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,591
Website

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

You too xaos? I got influenza at the end of March and took a good three weeks to recover. Even after the fever went down I felt exhausted - only just back to "normal" in the last week or so.

Please take it easy - we can push the new version of bl-exit when it's ready - and get well soon!


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#87 2016-06-24 09:40:22

MerlinElMago
Member
From: Canary Islands
Registered: 2016-06-23
Posts: 27

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Hello everybody,
it has alwasy appeared to me that the custom bl-exit tool was great, but it was not beautiful. And even knowing that is has been marked as "OBSOLETE" I have been working a little on it's aspect (leaving it's undelying functions untouched) and I have developed soemthing like this:

2016_06_24_10_28_27_scrot.png

Now my problem is that I cannot find any procedure whithin pyGTK to change the label color.
Does somebody have a clue how I could change it to white?

I guess the other possibility would be to remove the labels and insert images instead...

Regards
Merlin

Offline

#88 2016-06-24 10:24:44

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Googling "pygtk label color" produced this as the first hit: http://www.pygtk.org/pygtk2tutorial/sec … tyles.html


Be Excellent to Each Other...

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

Offline

#89 2016-06-24 10:36:50

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

@OP,

Notice that as of today a new version of bl-exit has been brought in production, which allows you to configure the visibility of the buttons in bl-exit.

Offline

#90 2016-06-24 10:55:51

MerlinElMago
Member
From: Canary Islands
Registered: 2016-06-23
Posts: 27

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

@damo
Yes I actually worked through that page, but it doesn't work for labels on buttons! That's the captcha...

@xaos52
Is that available on the msin repo?

Regards

Offline

#91 2016-06-24 11:01:53

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

I suppose you meant 'main' repo? smile
A normal apt-get update && apt-get upgrade will give you the new version of package bunsenlabs-utilities, containing the new version of bl-exit - which has quite some changes from the previous version - changes in the code that is, not in the appearance.

Offline

#92 2016-06-24 11:44:28

MerlinElMago
Member
From: Canary Islands
Registered: 2016-06-23
Posts: 27

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Will try that...

And of course I meant to say 'main', but I had quite a battle with my cellphone keyboard big_smile

Regards

Offline

#93 2016-06-24 19:36:17

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

@MerlinElMago:  Nice avatar and yes, the new bl-exit is quite different from the last version.  If you'd like to incorporate bl-lock with bl-exit (shoutout to xaos52 for the patch), check out this thread.

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

Offline

#94 2016-06-24 20:52:58

MerlinElMago
Member
From: Canary Islands
Registered: 2016-06-23
Posts: 27

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Well,
after all I managed to have a little spare time to hace a look at the script and write a quick and dirty hack to adapt it to my needs. Maybe in the future I implement a theme engine vía the script.

The menu is looking like that right now:
2016_06_24_21_39_48_scrot.png

Here is my code (it is really dirty! It needs a cleanup because lots of options that are now useless are still in):

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import print_function

import os
display = os.environ.get('DISPLAY') is not None

import sys
import getpass
import subprocess
import dbus

__me__ = 'bl-exit'
__version__ = '2.0.0'

# Translate command-line option to method - command line only
actionToMethod = dict(
    logout='Logout', l='Logout',
    suspend='Suspend', s='Suspend',
    hybridsleep='HybridSleep', y='HybridSleep',
    hibernate='Hibernate', i='Hibernate',
    reboot='Reboot', b='Reboot',
    poweroff='PowerOff', p='PowerOff'
)


class CanDoItError(Exception):
    pass


class BlexitBase(object):

    def __init__(self):
        self.dbus_iface = None

    def setup_dbus_connection(self):
        try:
            bus = dbus.SystemBus()
            dbus_object = bus.get_object('org.freedesktop.login1',
                                         '/org/freedesktop/login1')
            self.dbus_iface = dbus.Interface(dbus_object,
                                             'org.freedesktop.login1.Manager')
        except bus.DBusException as e:
            self.on_error(str(e))

    def can_do_action(self, action):
        # There is no 'CanLogout' method
        if action == "Logout":
            return "yes"
        actionMethod = "Can{}".format(action)
        response = self.send_dbus(actionMethod)
        return str(response)

    def do_action(self, action):
        print("do_action: {}".format(action), file=sys.stderr)
        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))

    def on_error(self, string):
        print ("{}".format(string), file=sys.stderr)
        sys.exit(1)

    def openbox_exit(self):
        subprocess.check_output(["openbox", "--exit"])

    def logout(self):
        try:
            self.openbox_exit()
        except subprocess.CalledProcessError as e:
            self.on_error(e.output)

    def action_from_command_line(self, action):
        try:
            self.do_action(action)
        except (subprocess.CalledProcessError, CanDoItError, KeyError) as e:
            self.on_error(str(e))

    def main(self):
        opts = get_options()
        if opts.logout:
            self.logout()
        else:
            if opts.suspend:
                action = "suspend"
            elif opts.hibernate:
                action = "hibernate"
            elif opts.hybridsleep:
                action = "hybridsleep"
            elif opts.reboot:
                action = "reboot"
            elif opts.poweroff:
                action = "poweroff"
            self.setup_dbus_connection()
            self.action_from_command_line(actionToMethod[action])

if display:
    """Testing for display here because we want to be able to run the script
    in a non-graphical environment as well. Importing gtk.Window on the console
    spits out some errors and crashes the application."""
    import gtk
    import pygtk
    pygtk.require('2.0')
    import ConfigParser

    class BlexitWindow(BlexitBase, gtk.Window):
        """A dialog offering the user to log out, suspend, reboot or shut down.
        """

        def __init__(self):
            BlexitBase.__init__(self)
            gtk.Window.__init__(self)

        def configure(self):
            """Determine config directory: first try the environment variable
            XDG_CONFIG_HOME according to XDG specification and as a fallback
            use ~/.config/bl-exit. Use /etc/bl-exit/bl-exitrc as a last
            resort."""
            config_dirs = []
            xdg_config_dir = os.getenv('XDG_CONFIG_HOME')
            if xdg_config_dir:
                config_dirs.append(xdg_config_dir)
            user_config_dir = os.path.expanduser('~/.config')
            try:
                if not (xdg_config_dir and os.path.samefile(user_config_dir,
                                                            xdg_config_dir)):
                    config_dirs.append(user_config_dir)
            except OSError as e:
                print ("{}: {}".format(__me__, str(e)), file=sys.stderr)
                pass
            config_dirs.append('/etc')
            config_file = None
            for config_dir in config_dirs:
                config_dir = config_dir + '/bl-exit'
                if os.path.isdir(config_dir):
                    maybe_config_file = config_dir + '/bl-exitrc'
                    if os.path.isfile(maybe_config_file):
                        config_file = maybe_config_file
                        self.saved_config_dir = config_dir
                        break

            if config_file:
                try:
                    self.config = ConfigParser.RawConfigParser()
                    self.config.read(config_file)
                except ConfigParser.ParsingError as e:
                    print ("{}: {}".format(__me__, str(e)), file=sys.stderr)
                    self.config = None
                    sys.exit(1)
            else:
                self.config = None

        def construct_ui(self):
            self.set_title("Log out " + getpass.getuser()
                           + "? Choose an option:")
            self.set_border_width(0)
            self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#222222'))
            self.set_size_request(-1, 120)
            self.set_resizable(False)
            self.set_keep_above(True)
            self.stick
            self.set_decorated(False)
            self.set_position(gtk.WIN_POS_CENTER)
            self.connect("delete_event", gtk.main_quit)
            windowicon = self.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_DIALOG)
            self.set_icon(windowicon)

            #Size our window to full width + 120px height
            self.set_size_request(gtk.gdk.screen_width(),120)

            # Cancel key (Escape)
            accelgroup = gtk.AccelGroup()
            key, mod = gtk.accelerator_parse('Escape')
            accelgroup.connect_group(key, mod, gtk.ACCEL_VISIBLE,
                                     gtk.main_quit)
            self.add_accel_group(accelgroup)
            self.button_box = gtk.HBox()
            self.button_box.set_size_request(-1, 120)
            self.add_button(1, self.cancel_action, stock='cancel')
            self.build_button_visibility_array()
            for button in self.bva:
                (action, label, actionfunc, method, show, onError) = button
                if not show == 0:
                    self.add_button(show, actionfunc, label=label, btype=action)
            self.status = gtk.Label()
            label_box = gtk.HBox()
            label_box.pack_start(self.status)

            vbox = gtk.VBox()
            vbox.pack_start(self.button_box)
            vbox.pack_start(label_box)

            self.add(vbox)
            self.show_all()
            #Don't use anything else!
            self.set_keep_above(True)

        def build_button_visibility_array(self):
            """Determine button visibily using bl-exit configuration file.
            Build self.bva, an array of tuples, one entry per button,
            containing (action, label, actionfunction, actionMethod, show,
            onerror)
            """
            self.bva = []
            bva = [('logout', '_Log out', self.logout_action),
                   ('suspend', '_Suspend', self.suspend_action),
                   ('hibernate', 'H_ibernate', self.hibernate_action),
                   ('hybridsleep', 'H_ybrid sleep', self.hybridsleep_action),
                   ('reboot', 'Re_boot', self.reboot_action),
                   ('poweroff', '_Power off', self.shutdown_action)]
            show_values = dict(never=0, always=1, maybe=2)
            """Values that the 'show' keyword can take in the configuration
            file."""
            onerror_values = dict(novisual=0, visual=1)
            """Values that the 'onerror' keyword can take in the configuration
            file."""
            # Per button default settings
            per_button_defaults = dict(
                logout='always',
                suspend='always',
                hibernate='never',
                hybridsleep='never',
                reboot='always',
                poweroff='always'
            )
            for (action, label, actionfunction) in bva:
                # Defaults.
                show = show_values[per_button_defaults[action]]
                onError = onerror_values['novisual']
                if self.config:
                    for section in ['default', action]:
                        try:
                            try:
                                getshow = self.config.get(section, 'show')
                                if getshow in show_values:
                                    show = show_values[getshow]
                                    if show == 2:
                                        candoit = self.can_do_action(
                                            actionToMethod[action])
                                        if not candoit == 'yes':
                                            show = 3
                            except ConfigParser.NoOptionError as e:
                                pass

                            try:
                                getonerror = self.config.get(section,
                                                             'onerror')
                                if getonerror in onerror_values:
                                    onError = onerror_values[getonerror]
                            except ConfigParser.NoOptionError as e:
                                pass
                        except ConfigParser.NoSectionError as e:
                            pass

                self.bva.append(tuple([action, label, actionfunction,
                                       actionToMethod[action], show,
                                       onError]))

        def main(self):
            self.configure()
            self.construct_ui()
            gtk.main()

        def add_button(self, show, action, label=None, stock=None, btype=None):
            if stock is not None:
                button = gtk.ColorButton(gtk.gdk.color_parse('#222222'))
		btype = stock
            else:
                button = gtk.ColorButton(gtk.gdk.color_parse('#222222'))
		button.set_title("Test")
            button.set_size_request(100, 40)
	    button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#222222"))
	    button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse("#222222"))
	    button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse("#222222"))
	    
            #No borders
            button.set_relief(gtk.RELIEF_NONE)
            image = gtk.Image()
            image.set_from_file(self.saved_config_dir+"/"+str(btype)+".png")
            button.set_image(image)

            if show == 3:
                button.set_sensitive(False)
            button.set_border_width(0)
            button.connect("clicked", action)
            self.button_box.pack_start(button)

        def disable_buttons(self):
            self.button_box.foreach(lambda button:
                                    button.set_sensitive(False))

        def cancel_action(self, button):
            self.disable_buttons()
            gtk.main_quit()

        def get_onerror(self):
            for item in self.bva:
                (action, label, actionfunction, actionMethod, show,
                 onerror) = item
                if action == self.selected_action:
                    return onerror

        def on_error(self, e):
            onerror = self.get_onerror()
            if onerror == 0:
                print ("{}: {}".format(__me__, str(e)), file=sys.stderr)
                sys.exit(1)
            else:
                emDialog = gtk.MessageDialog(parent=None, flags=0,
                                             type=gtk.MESSAGE_INFO,
                                             buttons=gtk.BUTTONS_OK,
                                             message_format=None)
                if emDialog:
                    emDialog.set_markup("{}".format(e))
                    emDialog.run()

        def logout_action(self, button):
            self.disable_buttons()
            self.selected_action = 'logout'
            self.status.set_label("Exiting Openbox, please standby...")
            self.openbox_exit()
            gtk.main_quit()

        def suspend_action(self, button):
            self.disable_buttons()
            self.selected_action = 'suspend'
            self.status.set_label("Suspending, please standby...")
            self.do_action("Suspend")
            gtk.main_quit()

        def hibernate_action(self, button):
            self.disable_buttons()
            self.selected_action = 'hibernate'
            self.status.set_label("Hibernating, please standby...")
            self.do_action("Hibernate")
            gtk.main_quit()

        def hybridsleep_action(self, button):
            self.disable_buttons()
            self.selected_action = 'hybridsleep'
            self.status.set_label("Hibernating + Sleeping, please standby...")
            self.do_action("HybridSleep")
            gtk.main_quit()

        def reboot_action(self, button):
            self.disable_buttons()
            self.selected_action = 'reboot'
            self.status.set_label("Rebooting, please standby...")
            self.do_action("Reboot")
            gtk.main_quit()

        def shutdown_action(self, button):
            self.disable_buttons()
            self.selected_action = 'poweroff'
            self.status.set_label("Shutting down, please standby...")
            self.do_action("PowerOff")
            gtk.main_quit()


def get_options():
    result = None
    import argparse
    parser = argparse.ArgumentParser(description="Bunsenlabs exit")
    if display:
        parser.add_argument("-l", "--logout", help="Log out",
                            action="store_true")
    parser.add_argument("-s", "--suspend", help="Suspend",
                        action="store_true")
    parser.add_argument("-i", "--hibernate", help="Hibernate",
                        action="store_true")
    parser.add_argument("-y", "--hybridsleep", help="Hybrid sleep",
                        action="store_true")
    parser.add_argument("-b", "--reboot", help="Reboot",
                        action="store_true")
    parser.add_argument("-p", "--poweroff", help="Power off",
                        action="store_true")
    parser.parse_args(sys.argv[1:])
    """No check if more than one option was specified. Take the first option and
    discard the other"""
    result = parser.parse_args()
    return result


def main():
    '''
    The script works both in a graphical and a non-graphical environment.

    In a graphical environment, the BlExitWindow instance is only shown when
    the script is launched without arguments. The user selects the action she
    wants by clicking the right button.

    WHen  the script is launched In a graphical environment the requested
    action should be one of the accepted arguments and the action is executed
    without asking for confirmation - as if the script was launched from the
    command line.

    In a non-graphical environment, one of the accepted actions must be
    specified as an argument.
    '''
    
    if display and len(sys.argv[1:]) == 0:
        blexit = BlexitWindow()
    else:
        blexit = BlexitBase()
    blexit.main()

if __name__ == "__main__":
    sys.exit(main())

As you can see, the images are interchangeable, they are actually stored in the same directory, the config file is in.

I hope you like it and I promise to post any update come up with.

Regards
Merlin

Last edited by MerlinElMago (2016-06-24 20:53:34)

Offline

#95 2016-06-24 20:57:11

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

MerlinElMago wrote:

.....
I hope you like it and I promise to post any update come up with.

Regards
Merlin

I do - your desktop looks really nice. And Yes, please smile


Be Excellent to Each Other...

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

Offline

#96 2016-06-24 21:10:34

MerlinElMago
Member
From: Canary Islands
Registered: 2016-06-23
Posts: 27

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

Glad you like it!

I obviously did only generate those images that *I* needed for my menu.

How can I upload a compressed file with the SVG File?

It would also be nice to have tooltips whenever y hover over the images... Well see how it do that.

Best regards
Merlin

Offline

#97 2016-06-24 21:32:11

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

MerlinElMago wrote:

...
How can I upload a compressed file with the SVG File?
...

Upload what, and where?

Why can't you just add an svg to an archive? Eg using zip:

zip zipname.zip file.sh file.png file.svg

Be Excellent to Each Other...

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

Offline

#98 2016-06-24 21:47:03

MerlinElMago
Member
From: Canary Islands
Registered: 2016-06-23
Posts: 27

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

I mean in this forum. I can't find any option to append a file to a thread.

Regards

Offline

#99 2016-06-24 22:05:51

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

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

MerlinElMago wrote:

I mean in this forum. I can't find any option to append a file to a thread.

Regards

You can't. But you can post a link to online storage (eg Dropbox).

...but an svg is basically a text file, so you could open it in a text editor and c&p the text here, with [ code ] tags.


Be Excellent to Each Other...

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

Offline

#100 2016-06-24 23:49:32

MerlinElMago
Member
From: Canary Islands
Registered: 2016-06-23
Posts: 27

Re: [OBSOLETE] The bunsenlabs 'exit' menu entry

ok... so here's where I'm at...

  • I've cleaned up the code.

  • I have moved many of the options from the code into the configuration file.

  • I have implemented a fade-in option.


Tomorrow I will have a look at it all and post the result. Basically it is now completely user configurable.

Here goes the svg file for the icons:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="210mm"
   height="297mm"
   viewBox="0 0 744.09448819 1052.3622047"
   id="svg2"
   version="1.1"
   inkscape:version="0.91 r13725"
   sodipodi:docname="Template.svg">
  <defs
     id="defs4" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1.6973651"
     inkscape:cx="372.04724"
     inkscape:cy="841.98376"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="true"
     showborder="false"
     inkscape:snap-path-mask="true"
     inkscape:snap-path-clip="true"
     objecttolerance="50"
     gridtolerance="50"
     guidetolerance="50"
     inkscape:snap-perpendicular="true"
     inkscape:snap-tangential="true"
     showguides="false"
     inkscape:guide-bbox="true"
     inkscape:window-width="1920"
     inkscape:window-height="1016"
     inkscape:window-x="0"
     inkscape:window-y="27"
     inkscape:window-maximized="1">
    <sodipodi:guide
       position="0,0"
       orientation="1,0"
       id="guide4138"
       inkscape:label=""
       inkscape:color="rgb(0,0,255)" />
    <sodipodi:guide
       position="0,0"
       orientation="0,1"
       id="guide4140" />
    <sodipodi:guide
       position="0,0"
       orientation="0,1"
       id="guide4142" />
    <sodipodi:guide
       position="0,0"
       orientation="0,1"
       id="guide4144" />
    <sodipodi:guide
       position="0,320.00001"
       orientation="0,1"
       id="guide4146"
       inkscape:label=""
       inkscape:color="rgb(0,0,255)" />
    <sodipodi:guide
       position="320,0"
       orientation="1,0"
       id="guide4148"
       inkscape:label=""
       inkscape:color="rgb(0,0,255)" />
  </sodipodi:namedview>
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
        <cc:license
           rdf:resource="http://creativecommons.org/licenses/by/3.0/" />
      </cc:Work>
      <cc:License
         rdf:about="http://creativecommons.org/licenses/by/3.0/">
        <cc:permits
           rdf:resource="http://creativecommons.org/ns#Reproduction" />
        <cc:permits
           rdf:resource="http://creativecommons.org/ns#Distribution" />
        <cc:requires
           rdf:resource="http://creativecommons.org/ns#Notice" />
        <cc:requires
           rdf:resource="http://creativecommons.org/ns#Attribution" />
        <cc:permits
           rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
      </cc:License>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Capa 1"
     inkscape:groupmode="layer"
     id="layer1">
    <path
       style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       d="m 447.75799,564.2023 a 99.518051,99.518044 0 0 0 -99.51759,99.51758 99.518051,99.518044 0 0 0 99.51759,99.51757 99.518051,99.518044 0 0 0 99.51953,-99.51757 99.518051,99.518044 0 0 0 -99.51953,-99.51758 z m 0,24.8789 a 74.638535,74.638535 0 0 1 74.63867,74.63868 74.638535,74.638535 0 0 1 -74.63867,74.63867 74.638535,74.638535 0 0 1 -74.63868,-74.63867 74.638535,74.638535 0 0 1 74.63868,-74.63868 z m -42.42579,14.10938 -18.10352,18.10351 42.42773,42.42579 -42.42773,42.42578 18.10352,18.10351 42.42579,-42.42578 42.42773,42.42578 18.10352,-18.10351 -42.42774,-42.42578 42.42774,-42.42579 -18.10352,-18.10351 -42.42773,42.42578 -42.42579,-42.42578 z"
       id="path4196"
       inkscape:connector-curvature="0"
       inkscape:export-xdpi="142.55"
       inkscape:export-ydpi="142.55" />
    <path
       id="path4201"
       d="m 447.75799,-195.80015 a 99.518051,99.518044 0 0 0 -99.51759,99.517588 99.518051,99.518044 0 0 0 99.51759,99.5175694 99.518051,99.518044 0 0 0 99.51953,-99.5175694 99.518051,99.518044 0 0 0 -99.51953,-99.517588 z m 0,24.8789 a 74.638535,74.638535 0 0 1 74.63867,74.638688 74.638535,74.638535 0 0 1 -74.63867,74.63867 74.638535,74.638535 0 0 1 -74.63867,-74.63867 74.638535,74.638535 0 0 1 74.63867,-74.638688 z"
       style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       inkscape:connector-curvature="0" />
    <path
       style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       d="m 451.8576,311.15334 -13.04687,12.93945 12.35937,11.9629 a 74.638535,74.638535 0 0 1 71.22656,74.46874 74.638535,74.638535 0 0 1 -57.6582,72.5879 l 11.46875,9.86718 -14.47461,15.95508 a 99.518051,99.518044 0 0 0 85.54492,-98.41016 99.518051,99.518044 0 0 0 -95.41992,-99.37109 z m -17.25781,0.83789 a 99.518051,99.518044 0 0 0 -86.35938,98.5332 99.518051,99.518044 0 0 0 95.62891,99.37891 l 13.03125,-12.92383 -12.375,-11.97851 a 74.638535,74.638535 0 0 1 -71.40626,-74.47657 74.638535,74.638535 0 0 1 58.24415,-72.7207 l -11.33008,-9.71094 14.56641,-16.10156 z"
       id="path4221"
       inkscape:connector-curvature="0"
       inkscape:export-xdpi="142.55"
       inkscape:export-ydpi="142.55" />
    <g
       id="g4245"
       style="stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-opacity:1"
       transform="translate(284.9364,-749.80653)"
       inkscape:export-xdpi="142.55"
       inkscape:export-ydpi="142.55">
      <path
         id="path4236"
         d="m 162.82159,807.34058 a 99.518051,99.518044 0 0 0 -99.517584,99.51758 99.518051,99.518044 0 0 0 99.517584,99.51754 99.518051,99.518044 0 0 0 99.51953,-99.51754 99.518051,99.518044 0 0 0 -99.51953,-99.51758 z m 0,24.8789 a 74.638535,74.638535 0 0 1 74.63867,74.63868 74.638535,74.638535 0 0 1 -74.63867,74.63867 74.638535,74.638535 0 0 1 -74.638674,-74.63867 74.638535,74.638535 0 0 1 74.638674,-74.63868 z"
         style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
         inkscape:connector-curvature="0" />
      <path
         inkscape:connector-curvature="0"
         id="path4238"
         d="m 153.54385,967.27702 a 61.134556,61.134556 0 0 0 69.74754,-51.09022 61.134556,61.134556 0 0 0 0.62395,-7.89039 43.471056,44.420352 8.7771516 0 1 -47.38918,28.32714 43.471056,44.420352 8.7771516 0 1 -36.18323,-50.53373 43.471056,44.420352 8.7771516 0 1 40.40488,-37.61602 61.134556,61.134556 0 0 0 -8.54662,-2.03454 61.134556,61.134556 0 0 0 -69.74754,51.09022 61.134556,61.134556 0 0 0 51.0902,69.74754 z"
         style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
      <path
         inkscape:transform-center-y="0.70005751"
         inkscape:transform-center-x="0.74785586"
         d="m 180.30497,881.07244 -9.94361,-0.1791 -5.78472,8.08977 -2.90241,-9.51228 -9.48142,-3.00172 8.14983,-5.69982 -0.0751,-9.94494 7.93928,5.98961 9.43499,-3.1446 -3.24308,9.4016 z"
         inkscape:randomized="0"
         inkscape:rounded="0"
         inkscape:flatsided="false"
         sodipodi:arg2="1.104786"
         sodipodi:arg1="0.47646742"
         sodipodi:r2="7.4881358"
         sodipodi:r1="14.976272"
         sodipodi:cy="874.20367"
         sodipodi:cx="166.99675"
         sodipodi:sides="5"
         id="path4243"
         style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
         sodipodi:type="star" />
    </g>
    <g
       id="g4257"
       transform="translate(288.75408,24.192707)"
       style="stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-opacity:1"
       inkscape:export-xdpi="142.55"
       inkscape:export-ydpi="142.55">
      <path
         id="path4250"
         d="m 130.41406,797.57812 a 99.518051,99.518044 0 0 0 -70.927732,95.28321 99.518051,99.518044 0 0 0 99.517582,99.51758 99.518051,99.518044 0 0 0 99.51953,-99.51758 99.518051,99.518044 0 0 0 -70.92774,-95.23828 l 0,26.3164 a 74.638535,74.638535 0 0 1 46.04688,68.92188 74.638535,74.638535 0 0 1 -74.63867,74.63867 74.638535,74.638535 0 0 1 -74.638676,-74.63867 74.638535,74.638535 0 0 1 46.048826,-68.875 l 0,-26.40821 z"
         style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
         inkscape:connector-curvature="0" />
      <rect
         style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
         id="rect4254"
         width="31.995613"
         height="117.48011"
         x="143.00708"
         y="776.4751"
         ry="15.997807" />
    </g>
    <g
       id="g4275"
       transform="matrix(0,1,-1,0,1281.4643,1151.196)"
       style="stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-opacity:1"
       inkscape:export-xdpi="142.55"
       inkscape:export-ydpi="142.55">
      <path
         inkscape:connector-curvature="0"
         style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
         d="M 0.08732,729.58277 A 99.518051,99.518044 0 0 0 -70.840412,824.86598 99.518051,99.518044 0 0 0 28.67717,924.38356 99.518051,99.518044 0 0 0 128.1967,824.86598 99.518051,99.518044 0 0 0 57.26896,729.6277 l 0,26.3164 a 74.638535,74.638535 0 0 1 46.04688,68.92188 74.638535,74.638535 0 0 1 -74.63867,74.63867 74.638535,74.638535 0 0 1 -74.638676,-74.63867 74.638535,74.638535 0 0 1 46.048826,-68.875 l 0,-26.40821 z"
         id="path4263" />
      <path
         id="rect4265"
         d="m 28.677734,679.08789 -48.511718,44.66211 32.550781,0 c -0.01088,0.2432 -0.03711,0.48254 -0.03711,0.72852 l 0,85.48437 c 0,8.86279 7.135262,15.99609 15.998046,15.99609 8.862785,0 15.998047,-7.1333 15.998047,-15.99609 l 0,-85.48437 c 0,-0.24598 -0.02623,-0.48532 -0.03711,-0.72852 l 32.552734,0 -48.513672,-44.66211 z"
         style="fill:#ffffff;fill-opacity:1;stroke:#8c8c8c;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
         inkscape:connector-curvature="0" />
    </g>
  </g>
</svg>

Have fun!

Last edited by MerlinElMago (2016-06-24 23:51:35)

Offline

Board footer

Powered by FluxBB