Why can't I make a Desktop shutdown icon?

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.

*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.

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?

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).

[quote=kvdman]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).
[/quote]
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?

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.

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.

[/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.

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/ShutdownProcess.cpp#1672

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.

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.

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.

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 icon,

right click>add-ons>file type.

drag a new hvif icon to the ‘icon’ placeholder. save

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

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.

This bug should be fixed in r38899.

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.

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

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.

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).