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

Be excellent to each other!

#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?

Offline

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

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

Re: How about a simple logout?

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?

Offline

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

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

Re: How about a simple logout?

<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>

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?

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?

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.

Offline

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

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

Re: How about a simple logout?

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?

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

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?

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.

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?

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?

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?

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?

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

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?

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

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?

Offline

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

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

Re: How about a simple logout?

#!/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

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?

Offline

Help fund CrunchBang, donate to the project!

#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?

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

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: bleh

Debian Logo