where is the config or code behind the desktop "suspend" button?
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.)
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:
SysMenu item in the tray
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?
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.
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.)
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 04:29 PM.
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.
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.
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.
...
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.
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".
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
...
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.
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
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!
... 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.