LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices



Reply
 
Search this Thread
Old 07-17-2013, 04:14 PM   #1
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Rep: Reputation: 86
where is the config or code behind the desktop "suspend" button?


I'm running Mint-12 with Cinnamon. When I open the SysMenu from my tray, I see a button for Shutdown and friends. When I select that button, I get a dialog with more buttons:
  • Suspend
  • Hibernate
  • Restart
  • Shutdown
  • Cancel
If I select one of these buttons (except Cancel) stuff happens and programs run. I want to understand what is really going on.

Does the tray item run a program that draws the dialog?
Which program and where can I find it? I may want to "decorate" that dialog to suit my own tastes.

Does the dialog launch programs or scripts in response to each button?
If so, which programs and where do I find them?

Does the dialog throw an event which upstart uses
to match with a job to accomplish the requested actions?
NOTE -- Ubuntu and Mint rely on Upstart, running as pid=1 with the name 'init' for all sorts of things including system startup and system shutdown.
Are we really required to read the code for our Desktop Environment -- in my case Cinnamon -- to get answers to these questions?
I have not found any documentation anywhere. (I suspect I have not looked in the right places.)

Merci d'avance,
~~~ 0;-Dan
 
Old 07-17-2013, 08:18 PM   #2
frankbell
Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Mageia, Mint
Posts: 8,258

Rep: Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559Reputation: 1559
This article does not go into the details of the code, but it might be a good start:

http://www.advogato.org/article/913.html

If you do

Code:
apropos acpi
in a terminal, it will list man pages relevant to ACPI (Advanced Configuration and Power Interface) that will also help.

Last edited by frankbell; 07-17-2013 at 08:21 PM.
 
2 members found this post helpful.
Old 07-17-2013, 09:56 PM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,554

Rep: Reputation: 241Reputation: 241Reputation: 241
Normally the acpid daemon handles events. In debian the scripts for the events are located at /etc/acpi/events/. YMMV
 
1 members found this post helpful.
Old 07-18-2013, 12:11 PM   #4
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Original Poster
Rep: Reputation: 86
Thanks to shadow_7 and frankbell for their replies and references.

Let's take shutdown as an example.
  • I can use the 'shutdown' command from the shell
  • I can use the 'telinit' command from the shell
  • I can somehow throw a 'runlevel' event
  • I can use power management features
All of these will cause all processes to stop and power to get turned off. At the core, they might all result in the exact same things happening. (I have not read the code for the 'shutdown' command.)

From the desktop, with my mouse, I click twice:
  1. SysMenu item in the tray
  2. Shutdown button in the resulting dialog box
Somewhere in the code for the dialog box, I'd expect to find something like:
Code:
//
// this is pseudo-code, not an actual code fragment
//
switch ( myButton ) {
...
case ( isShutdown( myButton ) ) {
    causeShutdown( );
}
...
}
My original post sought to learn what actually happens in the 'causeShutdown( )' function. It could use 'system( )' to run the shutdown command in a shell. That's pretty ugly so I suspect that other things happen. What happens?

Merci d'avance,
~~~ 0;-Dan
 
Old 07-19-2013, 05:04 PM   #5
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,554

Rep: Reputation: 241Reputation: 241Reputation: 241
In debian the power button event, as in you push the button for power on the computer. It triggers a script /etc/acpi/powerbtn-acpi-support.sh. Which checks for other scripts to run, but ultimately issues the following command.

# shutdown -h -P now "Power button pressed"

I normally just enter a "shutdown -h now" as root when I shutdown. It's easy enough and I normally have a root shell open, even on the desktop. But I like knowing what my computer is doing and normally take a minimalist approach. If I'm not using it, it's not running. With cpu and net meters in the task bar, so I know when things are not as I wish them at a glance.
 
Old 07-24-2013, 05:24 PM   #6
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by Shadow_7 View Post
In debian the power button event, as in you push the button for power on the computer. It triggers a script /etc/acpi/powerbtn-acpi-support.sh. Which checks for other scripts to run, ...
Since I run Linux Mint (Ubuntu derived which is Debian derived) I suspect that the desktop code simply "throws the ACPI event" same as the power button. Thus the same crank turns regardless of how one gets there. Part of my information quest seeks to simply confirm what happens.

I know?!? I know !! Read the code for my desktop environment,
... and we wonder why few but thoroughbred geeks use Linux.
(Well, maybe we don't wonder after all.)

Heavy sigh,
~~~ 8d;-/ Dan
 
Old 07-24-2013, 05:28 PM   #7
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by Shadow_7 View Post
Normally the acpid daemon handles events. In debian the scripts for the events are located at /etc/acpi/events/. YMMV
I use Linux Mint.
Code:
.....It is derived from Ubuntu.
.......... It is derived from Debian.
On my Mint workstation, I find
  • scripts -- in /etc/acpi
  • 'upstart' jobs -- in /etc/acpi/events
NOTE -- I think that I used the term jobs correctly for the various stanzas that tell 'upstart' (running as PID=1, "init" process) what to do when various events happen.

Last edited by SaintDanBert; 07-24-2013 at 05:29 PM.
 
Old 07-25-2013, 02:45 PM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,554

Rep: Reputation: 241Reputation: 241Reputation: 241
At least there is code to reference to actually know "for sure" what likely happens. If we take the time to audit the code. In most other OSes, in apple you trust, in microsoft you trust, in the NSA you trust. I say likely because even CPUs have bugs that do unintended things, throw in some questionable ram and underpowered circuitry and it's a tech lottery.
 
Old 07-25-2013, 09:22 PM   #9
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by Shadow_7 View Post
At least there is code to reference to actually know "for sure" what likely happens. If we take the time to audit the code. In most other OSes, in apple you trust, in microsoft you trust, in the NSA you trust. I say likely because even CPUs have bugs that do unintended things, throw in some questionable ram and underpowered circuitry and it's a tech lottery.
"We should not marvel that modern computer software has [defects]. Rather we should find awe in the fact that they work at all."

I heard this in a keynote speech years ago. I cannot remember who said it. They were talking about the test-ability of software systems and showed how even trivial, event-driven, GUI based applications can count the test cases with large enough numbers to be effectively infinite. The speaker went on to say that it was no wonder so many software publishers were letting their end-users do most of the testing in the manner of open source projects.

~~~ 8d;-Dan
 
Old 07-27-2013, 10:19 AM   #10
jdackle
Member
 
Registered: Apr 2010
Distribution: Debian, LMDE
Posts: 46

Rep: Reputation: 11
NOTE: I will be talking about terminal commands below, I expect the actual calls from the GUI to be made using the corresponding library functions, as you suggested in one of your posts.

To my best understanding, the command "/sbin/shutdown" will use init (the deprecated(?) "-n" option bypasses init for the shutdown - see "man shutdown").
/etc/init.d - all (most?) service scripts for all runlevels
/etc/rc0.d - scripts to be run at runlevel 0 (halt/poweroff)
/etc/rc5.d - the usual full-desktop running level
/etc/rc6.d - reboot

/sbin/halt, /sbin/poweroff and /sbin/reboot seem to be respectivelly equivalent to "shutdown -h -H -t now", "shutdown -h -P -t now" and "shutdown -r" (they are binary files though, not just wrapper-scripts)


For suspending and hibernating, "pm-suspend" and "pm-hibernate" might be used (though there are definitelly other options). Check "man pm-is-supported" to check whether those abilities are available on your system.

Not sure this is the kind of information you were looking for but... there it goes.
 
1 members found this post helpful.
Old 07-27-2013, 02:49 PM   #11
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by jdackle View Post
...
Not sure this is the kind of information you were looking for but... there it goes.
Thanks for this.
  • ANY information about the parts is useful to this thread.
  • (grin)With your favorite distribution, your features may vary.
  • Your description of [/b]/etc/init.d/...[/b] sounds like it is based on the SystemV-init technology. Many distros have moved to either systemd or upstart which are reactive event driven. That said, I know with Mint-* (derived from Ubuntu) they use upstart which somehow honors any SystemV-init parts available. Apparently this enables install and use of packages which require system start processing but have not made the switch to an event driven process.
As I said before, ANY information about how all of this works is valuable. Gentle reader, please add your tuppence to the pile.

~~~ 0;-Dan
 
1 members found this post helpful.
Old 07-27-2013, 06:35 PM   #12
jdackle
Member
 
Registered: Apr 2010
Distribution: Debian, LMDE
Posts: 46

Rep: Reputation: 11
Talking

That was a gentle post of yours, Dan! *grin*

Yes, last I checked about all that was several years ago (I'll hardly ever get the need, professionally, to go any deeper than database structuring, no need to touch the OS). And yes, by that time, the SystemV-init technology was rather "current".
When the upstart "thing" came up - or maybe just when I took notice of it (I think about the time I switched from Mandrake/Mandriva to Ubuntu) - I noticed it still used the init system, so gave it no more thought... Now I'm realising the init scripts are rather "legacy support".
 
1 members found this post helpful.
Old 07-28-2013, 04:36 PM   #13
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by jdackle View Post
That was a gentle post of yours, Dan! *grin*
Are you saying that I was critical ... but nicely?
I did not intend "criticism" but clarification.
ASIDE -- I find that many technical people function at the level of "unconscious competence" -- we don't know what we know. They can look at a pile of technical details and pluck out answers. When asked, they are hard pressed to tell anyone "how did you know/do that?"

There is a similar concept called "conscious competence." In other words, we know what we know. Similarly they know the boundaries of their knowledge and carefully wander those realms. These folks make the best teachers and explainers.

In this case, the '/etc/init.d/*' reference by itself spoke volumes to me because I've spent decades in that world. I also know that the same folder tree does double duty in the world of 'upstart'. Someone new to either set of features might get confused so I wrote a clarification.
Quote:
Originally Posted by jdackle View Post
...
When the upstart "thing" came up - or maybe just when I took notice of it (I think about the time I switched from Mandrake/Mandriva to Ubuntu) - I noticed it still used the init system, so gave it no more thought... Now I'm realising the init scripts are rather "legacy support".
I know that Ubuntu 08.04 used 'upstart' with a heavy reliance on legacy SystemV-init because I ran that edition. I believe that earlier Ubuntu editions also used 'upstart' to some degree.

Cordialement,
~~~ 0;-Dan
 
1 members found this post helpful.
Old 07-29-2013, 11:16 AM   #14
jdackle
Member
 
Registered: Apr 2010
Distribution: Debian, LMDE
Posts: 46

Rep: Reputation: 11
Quote:
Originally Posted by SaintDanBert View Post
Are you saying that I was critical ... but nicely?
I did not intend "criticism" but clarification.
No, I didn't think you were critical. It's just that your clarification showed me how off the mark my post was. And the way you showed me that was even nicer than a critical but gentle post.
Quote:
ASIDE -- I find that many technical people function at the level of "unconscious competence" -- we don't know what we know. They can look at a pile of technical details and pluck out answers. When asked, they are hard pressed to tell anyone "how did you know/do that?"

There is a similar concept called "conscious competence." In other words, we know what we know. Similarly they know the boundaries of their knowledge and carefully wander those realms. These folks make the best teachers and explainers.
Well, my degree is in Sociology and that aside of yurs is a good point. However, sometimes I myself just have trouble giving a quick and simple answer to how I did something relativelly complex (or which requires some previous "basic" background the receiver of my answer might or not have - in terms of human conscience and behaviour, "basic background" is a very very very variable thing). And what I just said doesn't at all invalidate the role of "unconscious competence", it's just another angle sprung off the subject.

Quote:
Originally Posted by SaintDanBert View Post
I know that Ubuntu 08.04 used 'upstart' with a heavy reliance on legacy SystemV-init because I ran that edition. I believe that earlier Ubuntu editions also used 'upstart' to some degree.
Yep, 2008 was about the time I made the switch. Checks!

Quote:
Originally Posted by SaintDanBert View Post
Cordialement,
~~~ 0;-Dan
Salutations cordiales,
Jean-D. Ackle
 
Old 07-29-2013, 11:38 PM   #15
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,368
Blog Entries: 3

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by jdackle View Post
... sometimes I myself just have trouble giving a quick and simple answer to how I did something relatively complex (or which requires some previous "basic" background the receiver of my answer might or not have - in terms of human conscience and behaviour, "basic background" is a very very very variable thing)...
Have you ever asked a yes or no question and gotten a dissertation in reply? Decades ago, I did that. My dear, good, friend and boss stopped the dissertation saying, "Answer yes or no, pause, then offer a brief sentence or two to explain why you chose your answer." Another time, he encouraged me to ask if they want or need an explanation beyond yes or no. This approach demands that you take 90 seconds to think before saying something (unless you like to shoot from the hip.)

Even complex information starts with something simple, "Can I do XYZ?"
An affirmative leads folks to the next logical steps, "How do I do XYZ?" and "How will it take?" Often, simple knowledge that a solution exists is enough to inform a person to research. All they need is the location of the first brick on the path* to the solution. ==My== next step usually takes the form of Socratic questions, "Have you tried ...?" and "Have you thought about ...?"

Cheers,
~~~ 0;-Dan

__________
* "path" -- I recently stopped saying "yellow brick road" because too few folks recognized the reference. Sigh, the grey hair is catching up with me.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove "Suspend" and "Hibernate" from the "Shut Down" applet cccc Debian 2 05-02-2011 11:05 AM
upon shutdown, pressed "suspend", now desktop completely dead, no response to anytrys cernutowoe11@gmail.com Linux - General 1 12-07-2010 03:35 PM
How to remove "Suspend Computer" button in KDE? killy9999 Suse/Novell 4 09-28-2008 01:29 PM
How do i remove/disable the "suspend" button?? adija Linux - General 3 01-25-2007 01:12 AM


All times are GMT -5. The time now is 07:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration