And for those graphical environment that uses dbus, can shutdown, halt,
hypernate, sleep by this: (hope you know how to read it (works for
Gnome... Can others confirm for other))
#$1 = method name
execute_dbus_method ()
{
dbus-send --session --dest=org.freedesktop.PowerManagement \
--type=method_call --print-reply --reply-timeout=2000 \
/org/freedesktop/PowerManagement \
org.freedesktop.PowerManagement.$1
if [ $? -eq 0 ]; then
echo "Failed"
fi
}
if [ "$1" = "suspend" ]; then
echo "Suspending"
execute_dbus_method "Suspend"
elif [ "$1" = "hibernate" ]; then
echo "Hibernating"
execute_dbus_method "Hibernate"
elif [ "$1" = "reboot" ]; then
echo "Rebooting"
execute_dbus_method "Reboot"
elif [ "$1" = "shutdown" ]; then
echo "Shutting down"
execute_dbus_method "Shutdown"
elif [ "$1" = "" ]; then
echo "command required: suspend, shutdown, hibernate or reboot"
else
echo "command '$1' not recognised, only suspend, shutdown, hibernate
or reboot are valid"
exit 1
fi
Jesper Staun Hansen wrote:
> In graphical environments is a normal user (read: non root person)
> allowed to shutdown/halt through for example Gnome. But I am not sure
> how Gnome does it.
> But then you would have to find out how xfce does it and how kde does it
> and how...
>
>
> Jesper
>
> Didier Ernotte wrote:
>
>> In Mac OSX (which is a Unix system), and Linux, there is a command
>> named "shutdown" or "shutdown now" most likely in "/sbin" to shutdown
>> the system. I'm pretty sure that you must be logged as "root" (super
>> user) to execute it. I don't know how you can grant your extension to
>> have root privilege to execute the shutdown. You can always create a
>> script that call the shutdown command, and give root privilege to
>> whoever runs the script, but that a big hole in the security of the
>> system.
>>
>> Didier
>>
>> */InBasic <[EMAIL PROTECTED]>/* wrote:
>>
>> hi
>>
>> As i don't have so much experience using Linux or Mac OS please
>> help me to find out shutdown commands in these two OSs
>>
>> In windows platform there are too many ways to turn
>> off/standby/hibernate System,
>>
>> In my extension (Auto Shutdown - InBasic)
>> <https://addons.mozilla.org/en-US/firefox/addon/5452> i use :
>>
>> var process = Components.classes["*@
>> mozilla.org/process/util;1 <http://mozilla.org/process/util;1>*"]
>>
>> .createInstance(Components.interfaces.nsIProcess);
>> process.init(*DLL or ExE Path*);
>> process.run (false, *args*, args.length);
>>
>> to send shutdown command as args to "Command Prompt" or windows
>> API (shell32.dll or PowrProf.dll , ... ),
>>
>> if any body know similar way for shutdown/Hibernate/Standby Mac or
>> Linux Please reply,
>>
>>
>> Any help will be appreciated,
>> InBasic
>>
>>
>>
>> _______________________________________________
>> Project_owners mailing list
>> [email protected]
>> https://www.mozdev.org/mailman/listinfo/project_owners
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Project_owners mailing list
>> [email protected]
>> https://www.mozdev.org/mailman/listinfo/project_owners
>>
>>
>
>
> _______________________________________________
> Project_owners mailing list
> [email protected]
> https://www.mozdev.org/mailman/listinfo/project_owners
>
>
>
_______________________________________________
Project_owners mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/project_owners