Why can't I make a Desktop shutdown icon?

Forum thread started by paulfxh on Fri, 2010-09-24 23:18

I used this command in a terminal

ln -s /boot/system/bin/shutdown /boot/home/Desktop

to provide an icon on the Desktop that I intended to use (from launchbox) to get a 1-click shutdown (or reboot).
However, when I click it I get this message
The application "shutdown" might be blocked on a modal plane
When I hit the "Kill application" in the same message box, the computer shuts down without problem.
However, if I run the command

/boot/system/bin/shutdown

in a terminal, the computer shuts down without any error message.
What's going on here?
Also, I cannot find any "reboot" application (equivalent to /boot/system/bin/shutdown) but it must be there somewhere but probably under an unexpected name.

Comments

Re: Why can't I make a Desktop shutdown icon?

*edit: what I previously wrote didn't work, the below does.

open StyledEdit, paste this in:

#!/bin/sh
cd /boot/system/bin
./shutdown

save it. right click it, go to 'get info'. mark it as executable.

if you want to restart, add the -r flag to shutdown.

there's probably a better way to do this but it works.

Re: Why can't I make a Desktop shutdown icon?

Thank you for the reply.
I was unaware of the -r switch to cause the shutdown app to reboot.
However, I'm still puzzled as to why the command

/boot/system/bin/shutdown

works without problems as does a script containing this command as you suggested.
However, a symlink to the very same command gives the error that I posted in my first post.
Note that I have used very similar symlinks (such as for WebPositive) without any problems.
Any clues?

Re: Why can't I make a Desktop shutdown icon?

Don't know, I'm not an expert, but most of the system binaries are only meant to be run from the terminal. Double clicking them will do nothing (well it might execute them, but most require other flags to do anything useful). That might be a bug with double-clicking shutdown and doing what it does. Ask on the mailing list.

This is where the script helps. The first line tells it to invoke the shell, then you can basically do anything you can do in Terminal (same commands).

Re: Why can't I make a Desktop shutdown icon?

kvdman wrote:

but most of the system binaries are only meant to be run from the terminal. Double clicking them will do nothing (well it might execute them, but most require other flags to do anything useful).

Thanks again for the reply.
However, I don't think I can agree with your view that binaries are only meant to be run from a terminal.
Every time you run any application, whether from an icon shortcut or a terminal or a script or whatever, the binary runs.
Anybody else got an opinion on why my symlink gives a The application "shutdown" might be blocked on a modal plane message?

Re: Why can't I make a Desktop shutdown icon?

Anybody else got an opinion on why my symlink gives a The application "shutdown" might be blocked on a modal plane message?

Because Haiku is trying to shutdown (ending processes) but it is running the application shutdown (which it can't terminate). So, you are left with killing the application/process.

In other words, you call shutdown to end the processes and power down the computer but it can't end shutdown process ( it is blocked from being terminated because it is running - can't terminate itself).

Sorry, that's as clear as I can make it. Hope it makes sense to you.

Re: Why can't I make a Desktop shutdown icon?

Thank you for that explanation which certainly makes sense to me.
However, I believe it would equally explain why running "/boot/system/bin/shutdown" in a terminal or in a script shouldn't work .............but they do!
So, I'm still puzzled.
Is there perhaps something I've overlooked in your explanation?
Also, what does "blocked on a modal plane" mean?
I've googled this expression and nothing at all of relevance came up.

Re: Why can't I make a Desktop shutdown icon?

[/quote]Every time you run any application, whether from an icon shortcut or a terminal or a script or whatever, the binary runs.[/quote]

Sure, it'll run and then end (most system apps), like I said, most of these apps have no GUI so you won't see anything happen, they are meant to run from the terminal or be scripted. i.e double-click 'ifconfig' it runs, takes resources to start and then quit, but shows absolutely nothing. Run it from the terminal, and you'll see it spits out your network information. To make it do anything though, you need to add paramaters and use the available flags from the terminal.

Re: Why can't I make a Desktop shutdown icon?

modal - of or pertaining to mode, manner, or form

Script and terminal run in command line mode. Symbolic link would run in a different (window) mode. ie: it tries to terminate the window application but can't because has to run to completion.

Follow this code to understand it better:
http://haiku.it.su.se:8180/source/xref/src/servers/registrar/ShutdownPro...

modal is set to false

if application is showing modal window it returns true and blocks shutdown.

1680 	if (!debugged)
1681 		modal = BPrivate::is_app_showing_modal_window(team);
 
1683 if (modal) {
1684 		// app blocks on a modal window
1685 		char buffer[1024];
1686 		snprintf(buffer, sizeof(buffer), "The application \"%s\" might be "
1687 			"blocked on a modal panel.", appName);

EDIT:
Simply put. Take your symbolic link and run it in terminal. Notice that it works (will shutdown Haiku). When you double click it, the link or program runs differently than from terminal. That is the best explanation I can give.

Re: Why can't I make a Desktop shutdown icon?

Thank you for your very comprehensive reply to my query.
This was very educational for me and everything now seems to be fitting into place.
You are correct because when I either dragged my symlink icon to a terminal or typed its address in a terminal, it functioned normally.
Indeed, your explanation fully justifies what kvdman had tried to tell me.
So, if I understand correctly, terminal commands and scripts operate in Haiku as if they ran at Run Level 3 in Linux while symlinks operate at Run Level 5.
Looks like I need to do some reading as I was unaware of this distinction.
Many thanks once again.

Re: Why can't I make a Desktop shutdown icon?

to paulfxh
actualy you could just make a small script to get the options "restart/shutdown/cancel" with the following script:(if that's what you want?
open Styled Edit type this, save it anywhere and make it executable.

#!/bin/sh
shutdown -a
that's it.

Re: Why can't I make a Desktop shutdown icon?

OK, sounds good, thank you.
Presumably, I just use "shutdown -r" for a reboot script.
BTW, do you know how I can change the icon on this script which at present is a very bland StyledEdit icon (w/o the pencil)?
Get Info shows the icon but I can't find how to change it.

Re: Why can't I make a Desktop shutdown icon?

re icon,

right click>add-ons>file type.

drag a new hvif icon to the 'icon' placeholder. save

Re: Why can't I make a Desktop shutdown icon?

Thank you.
That worked perfectly (well, once I had found where to get the icons :))

Re: Why can't I make a Desktop shutdown icon?

well now you got me curious screenshot! :-p

what would be cool, is shutdown + reboot scripts and nice icons and as a replicant...

launchbox should be made replicantable.

Re: Why can't I make a Desktop shutdown icon?

This bug should be fixed in r38899.

Re: Why can't I make a Desktop shutdown icon?

Thanks for this. I guess that version should be available in a day or two.
Incidentally, as the bug refers to the HDA audio driver, I think you meant to post to this thread.

Re: Why can't I make a Desktop shutdown icon?

If you'd read the changeset, the bug he's referring to has to do with your initial problem; the shutdown process (double-clicking shutdown binary).

http://dev.haiku-os.org/changeset/38899

Re: Why can't I make a Desktop shutdown icon?

test out the shutdown issue again with this newer version and let us know if it fixes it for you.

I always thought that's how things worked and didn't realize it was a bug.

Re: Why can't I make a Desktop shutdown icon?

Yes, I installed r38903 and the symlink that I used in my first post now provides a Desktop icon that shuts down the computer without errors.
So, looks like the "bug" is fixed.
However, I am unable to create a working Desktop icon for a computer reboot.
So while
ln -s /boot/system/bin/"shutdown -r" /boot/home/Desktop
certainly gives me an icon, I get an error when it's clicked (unable to resolve link).

Re: Why can't I make a Desktop shutdown icon?

ln -s /boot/system/bin/"shutdown -r" /boot/home/Desktop

that's because -r is a flag to be used in the terminal.

the proper way to test if the bug is resolved, is to navigate to /boot/system/bin with tracker, and double click the shutdown binary and see if it shuts down without error.

Re: Why can't I make a Desktop shutdown icon?

Yes, the Shutdown binary (/boot/system/bin) shuts down without error upon clicking in r38903 as does the symlink that I made.
However, based on your comment regarding my reboot attempt, it's impossible in Haiku to create a symlink to reboot simply because there is no reboot binary in Haiku.
Is this correct?
(It's really no big deal as the reboot script that you suggested some time ago works fine. But I'm just curious).

Re: Why can't I make a Desktop shutdown icon?

I think you should leave the symlink approach and do a bash script instead

Re: Why can't I make a Desktop shutdown icon?

'there is no reboot binary in Haiku.'

I don't think there is, and this is handled via the shutdown binary with the appropriate parameter.

Re: Why can't I make a Desktop shutdown icon?

zuMikkebe wrote:

I think you should leave the symlink approach and do a bash script instead

Yes you need to make a bash script or try yab to make a shutdown window for you:

Something like this:

#!/bin/sh
if [ "$(alert "Shutdown Script Example" "shutdown" "reboot")" == "reboot" ]; then
	shutdown -r
else
	shutdown
fi

Right click on the file and then select "get info". activate the permissions using the up-arrow and set permission to execute for all (user, group, other).

Links:

Add a icon: http://www.besly.de/menu/search/archiv/pref/haikuicon_eng.html

Re: Why can't I make a Desktop shutdown icon?

OK, thank you. That works fine.

Re: Why can't I make a Desktop shutdown icon?

that script works perfectly but the alert can't be skipped so it's better to add a cancel button

#! /bin/sh
 
case $(alert --info "Leave this system by:" "Shutdown" "Reboot" "Cancel") in
 
	"Shutdown")
 
			shutdown
 
			;;
 
	"Reboot")
 
			shutdown -r
 
			;;
 
	*)
 
			exit
 
			;;
 
 
esac

Once you have saved this file (it's better to save it in your home/config/bin) and added a icon (google for a shutdown.svg image) as lelldorin described, you can add a deskbar replicant too by saving another script to /boot/home/config/boot/launch, this should contain a similar code

#! /bin/sh
 
desklink "cmd=Shutdown:/bin/shutdown" "cmd=Reboot:/bin/shutdown -r" "cmd=Remove Replicant:desklink --remove=Shutdown" /boot/home/config/bin/Shutdown

this time there is no need for an icon but you have to mark it as executable like it was done with the previous file, once this script has been loaded a replicant should appear on deskbar, a primary mouse button click open the alert script, the secondary mouse button click shows a menu

sorry for this unsolicited reply, this seems to be a boring holiday morning

Re: Why can't I make a Desktop shutdown icon?

Is there any way to start the screensaver from the command line and add to this script?

Thanks,
hey68you

Re: Why can't I make a Desktop shutdown icon?

hey68you wrote:

Is there any way to start the screensaver from the command line and add to this script?

Thanks,
hey68you

I suppose this can be done invoking screen_blanker but I don't know if this has got any args

Re: Why can't I make a Desktop shutdown icon?

hey68you wrote:

Is there any way to start the screensaver from the command line and add to this script?

Thanks,
hey68you

http://betips.net/1997/09/09/run-screensavers-from-the-terminal/