SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-09-02 20:52:02

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

How about a simple logout?

How about a simple logout? I found this somewhere. It runs on yad.

#! /bin/bash

action=$(yad --width 300 --entry --title "System Logout" \
    --image=gnome-shutdown \
    --button="Switch User:2" \
    --button="gtk-ok:0" --button="gtk-close:1" \
    --text "Choose action:" \
    --entry-text \
    "Power Off" "Reboot" "Suspend" "Logout")
ret=$?

[[ $ret -eq 1 ]] && exit 0

if [[ $ret -eq 2 ]]; then
    gdmflexiserver --startnew &
    exit 0
fi

case $action in
    Power*) cmd="systemctl poweroff" ;;
    Reboot*) cmd="systemctl reboot" ;;
    Suspend*) cmd="ssystemctl suspend'" ;;
    Logout*) 
        case $(wmctrl -m | grep Name) in
            *Openbox) cmd="openbox --exit" ;;
            *) exit 1 ;;
        esac
        ;;
    *) exit 1 ;;        
esac

eval exec $cmd

Offline

Help fund CrunchBang, donate to the project!

#2 2015-09-02 20:58:50

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: How about a simple logout?

I use this one in my Openbox system:
https://bbs.archlinux.org/viewtopic.php?id=200527

It's a bit more complicated but it looks very stylish  cool

Also: https://github.com/BunsenLabs/bunsen-ut … er/bl-exit

Offline

#3 2015-09-02 21:16:29

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: How about a simple logout?

Head_on_a_Stick wrote:

I use this one in my Openbox system:
https://bbs.archlinux.org/viewtopic.php?id=200527

It's a bit more complicated but it looks very stylish  cool

Very nice!
As we are supposed to be simple...     simplelogout.jpg

Offline

#4 2015-09-02 21:16:45

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: How about a simple logout?

ostrolk wrote:

How about a simple logout? I found this somewhere. It runs on yad.

There are loads of scripts like this. Personally I would like to see something like it in BunsenLabs, instead of a python script, but ATM yad isn't in jessie yet.

Here is my version for Openbox (which can be used by those who don't like systemd commands) O:)
yad-exit


(PS @OP, you can use [ code ] tags instead of [ quote ] - it makes code MUCH easier to read wink )


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#5 2015-09-02 22:22:26

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: How about a simple logout?

damo wrote:
ostrolk wrote:

How about a simple logout? I found this somewhere. It runs on yad.

There are loads of scripts like this. Personally I would like to see something like it in BunsenLabs, instead of a python script, but ATM yad isn't in jessie yet.

Here is my version for Openbox (which can be used by those who don't like systemd commands) O:)
yad-exit


(PS @OP, you can use [ code ] tags instead of [ quote ] - it makes code MUCH easier to read wink )

I'll remember to use [ code ].
One can also use a simple pipe menu, so the exit options open right next to the menu.
You add the following to the menu.xml

<menu id="exit" label="Exit">
  <item label="Logout">
    <action name="Execute">
      <command>openbox --exit</command>
    </action>
  </item>
  <item label="Suspend">
    <action name="Execute">
      <command>systemctl suspend</command>
    </action>
  </item>
  <item label="Reboot">
    <action name="Execute">
      <command>systemctl reboot</command>
    </action>
  </item>
  <item label="Poweroff">
    <action name="Execute">
      <command>systemctl poweroff</command>
    </action>
  </item>
</menu>

Most_simple_logout.jpg

Last edited by ostrołęk (2015-09-02 22:29:08)

Offline

#6 2015-09-02 22:46:20

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: How about a simple logout?

ostrolk wrote:

One can also use a simple pipe menu, so the exit options open right next to the menu.....

Nice idea smile

(Although it isn't a pipemenu, but an ordinary static menu)


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#7 2015-09-02 23:06:08

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: How about a simple logout?

I use to use a very similar menu exit scheme - directly under [Hanger] - today I just use Debrief and a modified bl-exit script.
2015_09_02_19_58_12_Scrot11.jpg
Love Linux - it's so breaktweak-able.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#8 2015-09-03 02:04:53

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 4,148
Website

Re: How about a simple logout?

I think corenominal might have been having fun playing with python when he wrote bl-exit, but it does the job well and the visual interface is simple enough isn't it?

The exit-submenu idea for menu.xml is also appealing though. It would do no harm to have both that and bl-exit (for a keyboard shortcut) available.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
#! forum moderator    BunsenLabs

Offline

#9 2015-09-03 07:07:20

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: How about a simple logout?

damo wrote:
ostrolk wrote:

One can also use a simple pipe menu, so the exit options open right next to the menu.....

Nice idea smile

(Although it isn't a pipemenu, but an ordinary static menu)

Yes, it is a static menu. smile
You don't have to run around the desktop for the next action, less wrist work. You are actually trying to get off the computer.

Offline

#10 2015-09-03 15:12:25

nore
>2^9
From: Lakeland
Registered: 2009-11-28
Posts: 740

Re: How about a simple logout?

Python used to hate Unicode. What would it take to replace the button texts in bl-exit script with UTF-8 characters?

Offline

#11 2015-09-03 15:53:36

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: How about a simple logout?

@ nore:

Note: When executing a Python script that contains Unicode characters, you must put the following line at the top of the script, to tell Python that the code is UTF-8/Unicode formatted.

# -*- coding: utf-8 -*-

Source:  Python Unicode: Encode and Decode Strings (in Python 2.x)

And that already exists in bl-exit, the first 8 lines:

#!/usr/bin/python2
# -*- coding: utf-8 -*-

import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass

Go for it ...  wink

        #Logout button
        self.logout = gtk.Button("_þûñĉĦ Øûŧ")
        self.logout.set_border_width(4)
        self.logout.connect("clicked", self.logout_action)
        self.button_box.pack_start(self.logout)
        self.logout.show()

2015_09_03_13_07_23_Scrot11.jpg


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#12 2015-09-03 16:50:09

nore
>2^9
From: Lakeland
Registered: 2009-11-28
Posts: 740

Re: How about a simple logout?

Kuvakaappaus_03_09_2015_19_24_40.jpg
Thanks! This is what I call progress.

Offline

#13 2015-09-03 17:42:03

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: How about a simple logout?

You're more than welcome.  Looks nice - did you redo your OpenBox menu as well?

EDIT:  It was either damo or johnraff that redid that so any thanks go in that direction.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#14 2015-09-04 08:03:35

ohnonot
...again
Registered: 2012-05-22
Posts: 2,205

Re: How about a simple logout?

^ i can see that it's "user friendly" to have a logout script like this, but personally i have no use to start up another ui toolkit just for that - 3 menu entries (in a submenu so they don't get pressed accidentally) are totally sufficient - like in post #5.

/rant:
it took me surprisingly long to find that out - not until i tried archbang, so it isn't even my "idea".
there seems to be some inbred operating system convention that logging out has to produce a screen-centered dialog...

Offline

#15 2015-09-04 09:06:29

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: How about a simple logout?

I started learning how to create with gtkdialog yesterday. This is the result;
Session_logout.jpg
or without icons;
Logout.jpg
or without text.
Logout1.jpg

Last edited by ostrołęk (2015-09-04 11:11:30)

Offline

#16 2015-09-04 13:57:08

nore
>2^9
From: Lakeland
Registered: 2009-11-28
Posts: 740

Re: How about a simple logout?

ohnonot wrote:

there seems to be some inbred operating system convention that logging out has to produce a screen-centered dialog...

Switching power off by pressing the power button is enough for me, but I can see a reason for a double checking dialog. If you are an office worker in a corporate network, you don't want to lose 10 minutes of your life for rebooting just because you accidentally pressed the wrong button. "Configuring updates... Don't turn off your computer."

Offline

#17 2015-09-04 14:32:47

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2012-03-22
Posts: 1,026
Website

Re: How about a simple logout?

nore wrote:

Switching power off by pressing the power button is enough for me ...

Depends on how far away from other keys the poweroff button is ]:D

On mac powerbook the poweroff button is just above backspace key. And I have had few accidents by inadvertently pressing 'power off' key instead of desired 'delete character'. I was mad mad 8.( 8.( 8o 8o mad 8o mad sad

Later on, I learned about '/etc/systemd/logind.conf' file containing 'HandlePowerKey=' line, and since then I am all big_smile big_smile big_smile  cool


Postpone all your duties; if you die, you won't have to do them ..
--> The very new BL forum! <--

Offline

#18 2015-09-04 14:33:51

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2012-03-22
Posts: 1,026
Website

Re: How about a simple logout?

ostrolk wrote:

I started learning how to create with gtkdialog yesterday. This is the result;
http://s6.postimg.org/wm24xkgm5/Session_logout.jpg
or without icons;
http://s6.postimg.org/773m0t2jh/Logout.jpg
or without text.
http://s6.postimg.org/m4c31tfrx/Logout1.jpg

Nice. Care to share the code, please?


Postpone all your duties; if you die, you won't have to do them ..
--> The very new BL forum! <--

Offline

#19 2015-09-04 16:14:33

Nili
#! Die Hard
From: 127.0.0.1
Registered: 2013-03-20
Posts: 811
Website

Re: How about a simple logout?

Simple logout "reboot / poweroff"

alias reboot="systemctl reboot"
alias poweroff="systemctl poweroff"

command: /reboot /poweroff or enough to make a shurtcut key. wink


# Debian GNU/Linux 8:8.2 (netinst/stable)
# Packages Installed: 541
# Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt11-1+deb8u4 (2015-09-19) i686 GNU/Linux
# Startup finished in 2.850s (kernel) + 6.473s (userspace) = 9.324s

Offline

#20 2015-09-04 17:03:10

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: How about a simple logout?

Nili wrote:
alias reboot="systemctl reboot"
alias poweroff="systemctl poweroff"

Very elegant smile

Personally, I symlink systemctl to /usr/bin/{poweroff,reboot} so I can use it in shortcuts & menus as a normal user without including /sbin in $PATH

Offline

#21 2015-09-04 17:14:56

Nili
#! Die Hard
From: 127.0.0.1
Registered: 2013-03-20
Posts: 811
Website

Re: How about a simple logout?

Head_on_a_Stick wrote:

Very elegant smile

Personally, I symlink systemctl to /usr/bin/{poweroff,reboot} so I can use it in shortcuts & menus as a normal user without including /sbin in $PATH

systemd plus coins smile

I do the same regarding shortcuts  ]:D


# Debian GNU/Linux 8:8.2 (netinst/stable)
# Packages Installed: 541
# Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt11-1+deb8u4 (2015-09-19) i686 GNU/Linux
# Startup finished in 2.850s (kernel) + 6.473s (userspace) = 9.324s

Offline

#22 2015-09-04 18:01:39

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: How about a simple logout?

iMBeCil wrote:
ostrolk wrote:

I started learning how to create with gtkdialog yesterday. This is the result;
http://s6.postimg.org/wm24xkgm5/Session_logout.jpg
or without icons;
http://s6.postimg.org/773m0t2jh/Logout.jpg
or without text.
http://s6.postimg.org/m4c31tfrx/Logout1.jpg

Nice. Care to share the code, please?

With icons;

#!/bin/bash

ICONS=/usr/share/pixmaps

export SessionLogout=$(cat <<End_of_Text
<window title="Choose an option" window-position="1" resizable="false">
<vbox width="60" height="60">                             
     
<frame>           
	<hbox space-expand="true">
	  <hbox>
		  <button>
		  <label>Logout</label>
          <input file>"$ICONS/Logout.png"</input>
          <action>openbox --exit</action>
		  </button>
		</hbox>
        <hbox>
	     <button>
	     <label>Suspend</label>
          <input file>"$ICONS/Suspend.png"</input>
		  <action>systemctl --suspend</action>
          </button>
	    </hbox>
        <hbox>
          <button>
		  <label>Reboot</label>
		  <input file>"$ICONS/Reboot.png"</input>
		  <action>systemctl --reboot</action>
		  </button>
		</hbox>
        <hbox>
		  <button>
		  <label>Poweroff</label>
		  <input file>"$ICONS/Shutdown.png"</input>
		  <action>systemctl --poweroff</action>
		  </button>
		 </hbox>
	</hbox>
      </frame>
  <hbox>
    <button>
      <label>"Close"</label>
       <action>EXIT:cancel</action>
    </button>
   </hbox>
  </vbox>
</window>
End_of_Text
)
gtkdialog --program=SessionLogout
unset SessionLogout

Without icons,

#!/bin/bash

ICONS=/usr/share/pixmaps

export SessionLogout=$(cat <<End_of_Text
<window title="Choose an option" window-position="1" resizable="false">
<vbox width="60" height="60">                             
     
<frame>           
	<hbox space-expand="true">
	  
		<hbox>
		  <button>
		  <label>Logout</label>
          <action>openbox --exit</action>
		  </button>
		</hbox>
        <hbox>
	     <button>
	     <label>Suspend</label>
         <action>systemctl --suspend</action>
          </button>
	    </hbox>
        <hbox>
          <button>
		  <label>Reboot</label>
		  <action>systemctl --reboot</action>
		  </button>
		</hbox>
        <hbox>
		  <button>
		  <label>Poweroff</label>
		  <action>systemctl --poweroff</action>
		  </button>
		 </hbox>
	</hbox>
      </frame>
  <hbox>
    <button>
      <label>"Close"</label>
       <action>EXIT:cancel</action>
    </button>
   </hbox>
  </vbox>
</window>
End_of_Text
)
gtkdialog --program=SessionLogout
unset SessionLogout

From these two, you'd deduce how to have only icons without text.
You have to have gtkdialog installed for this to work.

Offline

#23 2015-09-04 18:10:19

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: How about a simple logout?

^ I can't see any bashisms in those scripts (unless I've missed something) -- they would run quicker and consume fewer resources if you used a /bin/sh shebang (in Debian at least).
wink

Offline

#24 2015-09-04 18:17:17

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: How about a simple logout?

Head_on_a_Stick wrote:

^ I can't see any bashisms in those scripts (unless I've missed something) -- they would run quicker and consume fewer resources if you used a /bin/sh shebang (in Debian at least).
wink

Hmm...what shall I say?
No comment. smile

Offline

Be excellent to each other!

#25 2015-09-04 22:04:23

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: How about a simple logout?

Nili wrote:
alias reboot="systemctl reboot"
alias poweroff="systemctl poweroff"

I don't type so well:

### Terminal ShutDown  ###
alias lot='kill -9 -1'
alias rbt='systemctl reboot'
alias off='systemctl poweroff'

First one is: "logout" and I figure if Windows can have a [Start] I can have an [off]  big_smile


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo