SEARCH

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

You are not logged in.

#1 2013-06-28 17:59:04

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

[Solved] CB-Exit script

Problem: Can't Reboot or Shutdown from Desktop without first stopping at the GDM logon screen.

I am running a #! Waldorf which obeys the script just fine.
I am also running Debians as Wheezy OpenBox and a Jessie OpenBox..
My problem is in trying to use the CB-Exit with the Debian OpenBox.
I also tried a Similar python script called Exit.py which is similar to the CB-Exit in Function but not in call.
Neither of the Scripts will work with my Debian OpenBox installs .
I have installed gdm3 in Debian and all supporting OpenBox files available from the repositories.

If someone can suggest some code changes or a more effective Script for Debian, I would appreciate the gesture.
BTW I also tried the command direct from the CLI which still dumped me back into the GDM Logon

Here are excerpts so you can see the differences of the two scripts in the calls to REBOOT and SHUTDOWN..

gdm-control --reboot && openbox --exit

You can see in the first script CB-EXIT I made a modification to a straight system call which like the original commented out line above it Also did not work correctly. Just dumped me into the GDM logon.
CB-EXIT.py

	def reboot_action(self,btn):
		self.disable_buttons()
		self.status.set_label("Rebooting, please standby...")
#		os.system("dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Reboot")
 		os.system("/sbin/reboot")

	def shutdown_action(self,btn):
		self.disable_buttons()
		self.status.set_label("Shutting down, please standby...")
#		os.system("dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown")
 		os.system("/sbin/halt")

EXIT.py

   # Reboot
   def reboot(self, widget):
       os.system("gdm-control --reboot && openbox --exit")
       #os.system("shutdown -r && openbox --exit")

   # Shutdown
   def shutdown(self, widget):
       os.system("gdm-control --shutdown && openbox --exit")

Last edited by sqlpython (2013-07-15 05:29:43)


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

Be excellent to each other!

#2 2013-06-28 18:03:25

pidsley
Window Mangler
Registered: 2012-05-23
Posts: 1,752

Re: [Solved] CB-Exit script

I just give my user sudo privileges with no password for /sbin/shutdown, and then add menu entries that call "sudo shutdown -r now" and "sudo shutdown -h now" (or I just type "sdn" in a terminal -- it's aliased to "sudo shutdown -h now").

Last edited by pidsley (2013-06-28 18:11:58)

Offline

#3 2013-06-29 09:13:16

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [Solved] CB-Exit script

In a standard #! setup you need to allow a normal user - without privileges - to shutdown the system:

* Unable to shutdown as normal user
Solution:
No need to bury your password in the python script.

Just edit /etc/pam.d/common-session:

# here are the per-package modules (the "Primary" block)
session	[default=1]			pam_permit.so
# here's the fallback if no module succeeds
session	requisite			pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
session	required			pam_permit.so
# Allow a normal user to shutdown te system                    <---
session required                        pam_loginuid.so        <---
# and here are more per-package modules (the "Additional" block)
session	required	pam_unix.so 
session	optional			pam_ck_connector.so nox11
# end of pam-auth-update config

Add the two lines marked with the arrows.

Offline

#4 2013-07-01 04:18:59

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

Re: [Solved] CB-Exit script

Thank You @pidsley doesn't even work from a CLI in OBox ...
Thank You @ xaos52  I made the changes to common-session as you suggested but no Dice.

In all cases from OBox be it a Script or a CLI direct command, I just get a logout to gdm login..
However the Xfce desktop of this same Debian Jessie install has no such issues and works perfectly for rebooting, shutdown etc..
I could always reinstall this to #! and go to a Testing repository list but this particular troubled OBox install has sentimental value having been updated from Lenny, to Squeeze, to Wheezy and now Jessie.. and I hate to see it go.
I do have a Waldorf install also which works the scripts perfectly...
Just that the refusal on the CLI in Obox has me scratching my head ????


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#5 2013-07-01 05:39:32

pidsley
Window Mangler
Registered: 2012-05-23
Posts: 1,752

Re: [Solved] CB-Exit script

That is very strange. You could try removing GDM and either try LightDM or no DM at all.

Offline

#6 2013-07-01 14:08:07

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

Re: [Solved] CB-Exit script

^ Good logical alternative but, I had lightDM originally installed for years. I had just recently replaced lightDM with gdm3 because of this problem.
  As I have Obox, FluxBox and Xfce4 installed to this particular Jessie I would find it inconvenient to not have a Logon manager.
Besides this seems to be a broken item to be resolved, no?

Some problems never seem to go away though. For years my Sid installation will not recognize the Super/Win Key for Keyboard Shorcuts. Although I have gone from version to version of Xfce. I have edited the user and /etc/ keyboard configs to no avail.
I hope this is not a new problem with Jessie that will always be with me.

Just wondering who else is running Jessie and does the Obox Reboot and Shutdown work from the Desktop?

Last edited by sqlpython (2013-07-01 14:09:02)


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#7 2013-07-01 14:34:09

pidsley
Window Mangler
Registered: 2012-05-23
Posts: 1,752

Re: [Solved] CB-Exit script

sqlpython wrote:

  As I have Obox, FluxBox and Xfce4 installed to this particular Jessie I would find it inconvenient to not have a Logon manager.

Not trying to be difficult, but you can call startx with an argument to easily switch window managers at run time. https://wiki.archlinux.org/index.php/Xi … FWM_choice
I just have several "exec" lines in my .xinitrc, and I uncomment the appropriate line when I want to switch WMs. But that's just the way I like to do things.

Besides this seems to be a broken item to be resolved, no?

It may just be the way my brain works, but I try not to beat my head on things that "should work" but don't. Automounting is a good example of this. If there's a workaround or a manual method that works and doesn't seem too ugly, I'll go for it. Although I admit there are times my OCD gets the better of me and I will spend hours tracking down a small issue that causes a meaningless error message to display during boot.

Sorry I'm not running Jessie and GDM so I can't be more useful.

Last edited by pidsley (2013-07-01 14:57:05)

Offline

#8 2013-07-01 18:27:48

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [Solved] CB-Exit script

@OP: post output of

ck-list-sessions

before calling cb-exit.
I suspect you have a consolekit session problem.

I use startx myself, no login manager.

Last edited by xaos52 (2013-07-01 18:28:24)

Offline

#9 2013-07-02 16:48:28

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

Re: [Solved] CB-Exit script

Here's the Stuff...

sqlpython@debian7:~$ ck-list-sessions
Session2:
	unix-user = '1000'
	realname = 'sqlpython'
	seat = 'Seat1'
	session-type = 'x11'
	active = TRUE
	x11-display = ':0'
	x11-display-device = '/dev/tty7'
	display-device = ''
	remote-host-name = ''
	is-local = TRUE
	on-since = '2013-07-02T16:36:13.918425Z'
	login-session-id = '4'

OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#10 2013-07-04 11:17:33

DigitalJedi
#! CrunchBanger
From: Gaza
Registered: 2012-11-20
Posts: 120

Re: [Solved] CB-Exit script

I just use these and they work fine without prompting password:

<item label="SHUTDOWN"><action name="Execute">
<command>halt -p</command>
</action></item>
<item label="REBOOT"><action name="Execute">
<command>reboot --reboot</command>
</action></item>

EDIT---
Just for clarifying where I use these:
~/.config/openbox/menu.xml

Last edited by DigitalJedi (2013-07-04 15:16:54)


"Do or do not. There is no try." ~ Master Jedi Yoda

Offline

#11 2013-07-04 13:02:30

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

Re: [Solved] CB-Exit script

^  Thanks will give it a try.  I don't even seem to get satisfaction from the command line though.... Curious...


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#12 2013-07-08 03:57:29

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

Re: [Solved] CB-Exit script

@DigitalJedi
Ok, Tried your methods  Reboot and Halt..
Didn't work correctly. In both cases No processes were politely shutdown.
The Jessie session shutoff as if I just pushed the On/Off Switch. Not a good method to end  a Session.
Thanks Anyway


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#13 2013-07-08 11:55:57

DigitalJedi
#! CrunchBanger
From: Gaza
Registered: 2012-11-20
Posts: 120

Re: [Solved] CB-Exit script

I was not aware of that, thanks for the tip.
Always learning... cool


"Do or do not. There is no try." ~ Master Jedi Yoda

Offline

#14 2013-07-09 11:40:19

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [Solved] CB-Exit script

@sqlpython
I can not reproduce your problem.

Here is what I did:
1. install jessy with debootstrap
2. tasksel install standard
3. install slim, openbox, xserver-xorg
4. copy /usr/bin/cb-exit from my primary system to /usr/bin/ in jessy

So, cb-exit is the only thing non-Debian on the system.

cb-exit works for all options: login, reboot, power off.
The last two options work for a normal user without root privileges without having to edit any config file.

Last edited by xaos52 (2013-07-09 11:41:11)

Offline

#15 2013-07-11 16:06:24

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

Re: [Solved] CB-Exit script

Sorry for the time lag..

WoW! @xaos52
You went above and beyond.. didn't expect that you would do an experimental install !!
Thank You for the time and effort.

I haven't used SLiM manager in a while and maybe that could be a key when combined with cb-exit.
I am going to give it a try this week end.

I have even gone as far as editing my sudo config to recognize NOPasswd for the shutdown reboot and halt commands.
But No Soap..

EDIT: BTW  Yesterday I did and Openbox Install with Sid. Complete with GDM3/tint2 and all the the OBox goodies that I could find.
      And just as with Jessie, cb-exit nor a direct command line request would not immediately Shutdown nor Reboot..
      Strange stuff.

Thanks Again

Last edited by sqlpython (2013-07-11 16:13:57)


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#16 2013-07-15 05:28:58

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 931

Re: [Solved] CB-Exit script

OK.. I can mark this thread Solved....
Thanks to the Dynamic Duo of Pidsley and the The Good Doctor  as well as DigitalJedi..
Much appreciated ...

My solution modified the python file that I use to bring up a dialog box with Buttons ..( just like cb-exit )
The Solution produces an ordinary shutdown of processes as the system reboots or shuts down.
The solution asks for a sudo/su password to reboot or shutdown...
If I don't want to continue the password I can ( I have already tried this ) add a line to the /etc/sudoers file like so

 ALL   ALL=NOPASSWD:/sbin/shutdown 

  As I said I tried this and it does work but I am going with the password so I don't accidently Click Reboot in the menu and ....
which removes root needed privledges to execute /sbin/shutdown

You can see the my code changes below as I had replaced (rewritten two lines) and you can see the pounded out # line That was replaced...
All works fine and I will keep the gdm3 logon manager..

class DoTheLogOut:

   # Cancel/exit
   def delete_event(self, widget, event, data=None):
       gtk.main_quit()
       return False

   # Logout
   def logout(self, widget):
       os.system("openbox --exit")

   # Reboot
   def reboot(self, widget):
       #os.system("gdm-control --reboot && openbox --exit")
       os.system("gksudo 'shutdown -r now'")

   # Shutdown
   def shutdown(self, widget):
       #os.system("gdm-control --shutdown && openbox --exit")
       os.system("gksudo 'shutdown -h now'") 

Edit: Last line  -r  to  -h

Last edited by sqlpython (2013-07-16 02:37:10)


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#17 2014-06-09 20:27:44

zubcho81
#! CrunchBanger
From: Sofia, Bulgaria
Registered: 2012-08-12
Posts: 209

Re: [Solved] CB-Exit script

Can you post the whole script please?

Last edited by zubcho81 (2014-06-09 20:29:02)


Dried frog pills
As their name suggests, these are pills made chiefly from frogs, specifically the extremely poisonous ones that live in the vivarium at Unseen University and handled by the first-year students, so that if they kill one of them, not too much education has been wasted.

I use them daily! tongue

Offline

#18 2014-06-09 21:39:45

Alad
Software Satan
Registered: 2014-02-20
Posts: 1,512

Offline

#19 2014-06-09 22:52:57

Ozitraveller
#! Junkie
From: Far from the madding crowd!
Registered: 2011-04-26
Posts: 289
Website

Re: [Solved] CB-Exit script

I have a version of cb-exit running on debian stable and sid currently for openbox and fluxbox, both with/without DM and it works flawlessly.

I only time I had problems  was when I forgot to install policy kit.

Offline

#20 2014-06-10 15:15:58

zubcho81
#! CrunchBanger
From: Sofia, Bulgaria
Registered: 2012-08-12
Posts: 209

Re: [Solved] CB-Exit script

sqlpython wrote:

OK.. I can mark this thread Solved....
Thanks to the Dynamic Duo of Pidsley and the The Good Doctor  as well as DigitalJedi..
Much appreciated ...

My solution modified the python file that I use to bring up a dialog box with Buttons ..( just like cb-exit )
The Solution produces an ordinary shutdown of processes as the system reboots or shuts down.
The solution asks for a sudo/su password to reboot or shutdown...
If I don't want to continue the password I can ( I have already tried this ) add a line to the /etc/sudoers file like so

 ALL   ALL=NOPASSWD:/sbin/shutdown 

  As I said I tried this and it does work but I am going with the password so I don't accidently Click Reboot in the menu and ....
which removes root needed privledges to execute /sbin/shutdown

You can see the my code changes below as I had replaced (rewritten two lines) and you can see the pounded out # line That was replaced...
All works fine and I will keep the gdm3 logon manager..

class DoTheLogOut:

   # Cancel/exit
   def delete_event(self, widget, event, data=None):
       gtk.main_quit()
       return False

   # Logout
   def logout(self, widget):
       os.system("openbox --exit")

   # Reboot
   def reboot(self, widget):
       #os.system("gdm-control --reboot && openbox --exit")
       os.system("gksudo 'shutdown -r now'")

   # Shutdown
   def shutdown(self, widget):
       #os.system("gdm-control --shutdown && openbox --exit")
       os.system("gksudo 'shutdown -h now'") 

Edit: Last line  -r  to  -h

Sorry I meant this script. I need to use pm-suspend --quirck-dpms-on on the suspend button and on laptop closing and Fn+Suspend key. Because when I use cb-exit suspend button it will not suspend the laptop. So I don't know what to do.

Last edited by zubcho81 (2014-06-10 15:16:42)


Dried frog pills
As their name suggests, these are pills made chiefly from frogs, specifically the extremely poisonous ones that live in the vivarium at Unseen University and handled by the first-year students, so that if they kill one of them, not too much education has been wasted.

I use them daily! tongue

Offline

#21 2014-06-10 18:39:54

Alad
Software Satan
Registered: 2014-02-20
Posts: 1,512

Re: [Solved] CB-Exit script

Season as needed. Replace in:

def suspend_action(self,btn):
		self.disable_buttons()
		self.status.set_label("Suspending, please standby...")
		os.system("cb-lock")
		os.system("dbus-send --system --print-reply --type=method_call --reply-timeout=2000 --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend")
		gtk.main_quit()

os.system(...) with

os.system("pm-suspend --quirck-dpms-on")

Last edited by Alad (2014-06-10 18:40:15)

Offline

#22 2014-06-10 20:15:16

zubcho81
#! CrunchBanger
From: Sofia, Bulgaria
Registered: 2012-08-12
Posts: 209

Re: [Solved] CB-Exit script

Ok, I'm sorry about that but this command is working, but only in geany with F5 sad I'm saving this script with the command and nothing happens when I press suspend sad

some debug info:

This utility may only be run by the root user.

I have added this in /etc/sudoers

ALL     ALL=NOPASSWD:/usr/sbin/pm-suspend

I think something is wrong in my /etc/sudoers

Last edited by zubcho81 (2014-06-10 20:30:57)


Dried frog pills
As their name suggests, these are pills made chiefly from frogs, specifically the extremely poisonous ones that live in the vivarium at Unseen University and handled by the first-year students, so that if they kill one of them, not too much education has been wasted.

I use them daily! tongue

Offline

#23 2014-06-25 05:35:38

Eagleshadow
#! Member
Registered: 2014-06-02
Posts: 59

Re: [Solved] CB-Exit script

Now For Something Completely Different  neutral
I am posting this curiousity here since I am afraid that another Gentlemen has given up on teaching me anything (I don't blame him!).  I have been trying to add a shutdown wave to cb-exit.  I was told to add this to the script below but to use my own /path/to/file for the wav file.
               def logout_action(self,btn):
                    self.disable_buttons()
                    self.status.set_label("Exiting Openbox, please stand by...")
Add this-> os.system("aplay ~/crunchbang-configuration/startup-shutdown/door_close_1.wav")
                    os.system("openbox --exit")

I added this argument ("aplay /home/william/Soundfiles/tada.wav")  where directed.  Running this in terminal (aplay /home/william/Soundfiles/tada.wav) plays the wav file perfectly. My final edit looked like this: I haven't done the 1 space indent implied above as it seems changing the indentation keeps breaking the script and wiping out my shutdown panel when I execute Super-X

   def logout_action(self,btn):
                    self.disable_buttons()
                    self.status.set_label("Exiting Openbox, please stand by...")
                    os.system("aplay /home/william/Soundfiles/tada.wav")   
                    os.system("openbox --exit")

This doesn't break anything but it doesn't work either( no sound). If I don't fix this  birds will continue fly but I am a stubborn old guy on a mission. Is the syntax correct or am I doing it all wrong?

smile sad monkey newbie guy! BTW Cruncbang has resurrected my old Dell Inspiron 600m from the XP trash heap and works great in all respects tada.wav or not. smile

Offline

#24 2014-06-25 13:22:55

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

Re: [Solved] CB-Exit script

@Eagleshadow that aplay thing might be because it is not being run as you. I don't know python (but know that indentation matters btw) but am wondering who exactly the os.system call is running as. This is because I had a similar issue with a login script recently. It was running as root and so didn't have the necessary pulse audio cookie or something to aplay a wav file in the default mode.

After a lot of Googling around I tried

aplay -D plughw -q /path/to/sound.wav

which worked for me. Before you dive into it you could give that a try...


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

Offline

Help fund CrunchBang, donate to the project!

#25 2014-06-25 22:46:23

Eagleshadow
#! Member
Registered: 2014-06-02
Posts: 59

Re: [Solved] CB-Exit script

Are you proposing that I try this in the script?
os.system("aplay -D plughw -q /home/william/Soundfiles/tada.wav")

Eagleshadow

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.

Debian Logo