You are not logged in.

#1 2008-01-19 18:38:44

synthead
Member
Registered: 2006-05-09
Posts: 1,337

A better way to shutdown?

I've always done a telinit 0 or simply "poweroff" when I decide to turn my computer off, but that kills programs without asking about saving things, firefox always starts up saying it has crashed, etc.  Is there a better way to turn off the machine?

Offline

#2 2008-01-19 18:43:34

ise
Developer
From: Karlsruhe / Germany
Registered: 2005-10-06
Posts: 404
Website

Re: A better way to shutdown?

What desktop environment are you using? Do you use gdm, kdm, etc for login?

Offline

#3 2008-01-19 18:48:44

synthead
Member
Registered: 2006-05-09
Posts: 1,337

Re: A better way to shutdown?

I use XFCE4 and I have it autologin to my user in the inittab to runlevel 5.

Offline

#4 2008-01-19 19:04:54

ise
Developer
From: Karlsruhe / Germany
Registered: 2005-10-06
Posts: 404
Website

Re: A better way to shutdown?

Another solution maybe. Install gdm, start it on boot, configure it for autologin and then you have a "normal" shutdown possibility within xfce. Normally xfce should save your session then, if xfce support session management. Don't know, I don't use it.

Last edited by ise (2008-01-19 19:05:33)

Offline

#5 2008-01-19 20:33:25

xd-0
Member
From: Sweden
Registered: 2007-11-02
Posts: 327
Website

Re: A better way to shutdown?

sudo shutdown -h now

From man:
      "shutdown  brings  the system down in a secure way.  All logged-in users
       are notified that the system is going down, and  login(1)  is  blocked.
       It is possible to shut the system down immediately or after a specified
       delay.  All processes are first notified that the system is going  down
       by the signal SIGTERM.  This gives programs like vi(1) the time to save
       the file being edited, mail and news processing programs  a  chance  to
       exit  cleanly,  etc... "

It needs the following row in sudoers:
user ALL=NOPASSWD:/sbin/shutdown

Where user are your user name.

Offline

#6 2008-01-19 20:38:43

ise
Developer
From: Karlsruhe / Germany
Registered: 2005-10-06
Posts: 404
Website

Re: A better way to shutdown?

xd-0 wrote:

sudo shutdown -h now

This will kill (SIGTEMP) all programs, too. You can just specify a time, that's all. I think, synthead want something like session management, that all programs started which were running at the shutdown.

Offline

#7 2008-01-19 21:45:41

theringmaster
Member
From: Air Force
Registered: 2007-07-16
Posts: 581
Website

Re: A better way to shutdown?

I would use the 'halt' command. It does what I want it to do, that is shut down the computer.


Check me out on twitter!!! twitter.com/The_Ringmaster

Offline

#8 2008-01-19 22:25:27

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: A better way to shutdown?

Use /usr/lib/xfce4/xfsm-shutdown-helper
Cleanest method.

Offline

#9 2008-01-20 00:13:31

peart
Member
From: Kanuckistan
Registered: 2003-07-28
Posts: 510

Re: A better way to shutdown?

Misfit138 wrote:

Use /usr/lib/xfce4/xfsm-shutdown-helper
Cleanest method.

xfsm-shutdown-helper just calls shutdown hmm  See http://svn.xfce.org/index.cgi/xfce/brow … own-helper

I haven't found the source code to xfce's logout/shutdown button yet, still looking.  When I use that button, OpenOffice does offer to save before quitting.  Firefox just terminates, and would nag me on startup too, except that I disabled the nagging with an option in "about:config".

Offline

#10 2008-01-21 17:38:32

nachof
Member
Registered: 2008-01-18
Posts: 15

Re: A better way to shutdown?

What I did is use suspend instead of shutdown.

Add resume=/dev/sda5 to your kernel line (/dev/sda5 is your swap partition). Install lilo if that's what you're using.

Modify /etc/acpi/handler.sh so it says:

        button/power)
                #echo "PowerButton pressed!">/dev/tty5
                case "$2" in
                        PWRF)
                                logger "PowerButton pressed: $2"
                                acpitool -S
                                ;;
                        *)    logger "ACPI action undefined: $2" ;;
                esac
                ;;

Just press your power button and go to sleep. It will suspend to disk, and when you turn it on it will come back exactly as it was before.

Offline

#11 2008-01-21 17:52:25

diamondmind
Member
From: Lexington
Registered: 2007-12-19
Posts: 31

Re: A better way to shutdown?

xd-0 wrote:

sudo shutdown -h now

That's how I learned when I first switched to Linux and it's always worked for me ... reboots too. smile

nachof wrote:

What I did is use suspend instead of shutdown.

I've actually started suspending instead of total shutdown on my desktop now too. cool

Offline

#12 2008-01-22 04:21:51

dumas
Member
From: Sydney
Registered: 2007-09-01
Posts: 103

Re: A better way to shutdown?

I just found a very simple way about a week ago: wmctrl. It's available in AUR.
Use wmctrl -c $windowname or wmctrl -i -c $windowid to close a window as if you clicked on the close button in the title bar. I tried it on firefox, and it didn't report any crash or anything. Write a simple bash script to recursively close all windows, then power off.

Edit: Just wrote and tried that myself, works well.

#!/bin/bash
windows=`wmctrl -l | cut -d' ' -f1`
wmctrl -i -c $windows
while [ -n "$windows" ]; do
    windows=`echo $windows | cut -d' ' -f1 -s --complement`
    wmctrl -i -c $windows
done
halt

Don't run that in a terminal, because the script would close the terminal and terminates the script before it can call halt. For example, I run it in fluxbox and I put this script in my fluxbox menu. As you use XFCE, maybe put it in your menu or launch bar.

Last edited by dumas (2008-01-24 07:35:33)

Offline

Board footer

Powered by FluxBB