LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How do I run "menu" and "logout" from the command line in fluxbox? (https://www.linuxquestions.org/questions/slackware-14/how-do-i-run-menu-and-logout-from-the-command-line-in-fluxbox-864919/)

ewsmith 02-27-2011 09:48 AM

Quote:

Originally Posted by dh2k (Post 4272758)
EDIT:
Thinking about this I would probably recommend just invoking the (fluxbox-remote "FLUXBOX_INTERNAL_COMMAND") command;

then it is upto you to consider the system shutdown which would require updating the sudoers file (visudo as root).


So to summarise:
Code:

i: /usr/share/pixmaps/lucid/pngs/system.png
c: fluxbox-remote "RootMenu"
t: Menu


i: /usr/share/pixmaps/lucid/pngs/system-switch-user.png
c: if xmessage center -buttons No:1,Yes:0 "Really logout?"; then fluxbox-remote "Exit"; fi
t: Logout


i: /usr/share/pixmaps/lucid/pngs/system-shutdown.png
c: if xmessage -center -buttons No:1,Yes:0 "Really shutdown?"; then sudo /sbin/halt; fi
t: Shutdown

So, be sure to change/personalise the icon paths and this will work -

or you could have the button execute a bash script that creates a dialog and askes you.
on my openbox i use this:
Code:

#!/bin/bash

gxmessage "Are you sure you want to shut down your computer?" -center -title "Take action" -font "Sans bold 10" -default "Cancel" -buttons "_Cancel":1,"_Log out":2,"_Reboot":3,"_Shut down":4 >/dev/null

case $? in
        1)
                echo "Exit";;
        2)
                openbox --exit;;
        3)
                sudo /sbin/shutdown -r now;;
        4)
                sudo /sbin/shutdown -hP now;;
esac

just replace the commands to match your system.

gnashley 02-27-2011 12:54 PM

So, fluxbox does have a 'remote' feature -great to hear it. Using that would be the method to most closely match what the OP asked for.

dh2k 02-27-2011 01:09 PM

yeah, that seems so - however the dev's at fluxbox roll it out disabled by default - I would like to look into why this is so. I guess some slim to none security issue (like a hacker script to invoke the command and the user logout/Exit) maybe - maybe not?


Should really email this upstream as it is a really good feature of fluxbox - only for it to be disabled by default - will update.

dh2k 02-27-2011 02:01 PM

I asked at #fluxbox on freenode.org and they pointed out it is mentioned in manual pages "man fluxbox-remote"
Quote:

fluxbox-remote(1) uses the X11 protocol to communicate with fluxbox(1). Therefore, it is possible for any user with access to the X(7) server to use fluxbox-remote(1). For this reason, several key commands have been disabled. Users should be aware of the security implications when enabling fluxbox-remote(1), especially when using a forwarded X(7) connection.
Can any mod' or slack-guru put this into laymans? e.g. what type of user could get access to my X session?

psionl0 03-02-2011 12:46 AM

This is just what I was looking for dh2k. I have decided to leave the shutdown commands for the menu only and only use the buttons for logging out. It works great now.

Thanks for your assistance.


All times are GMT -5. The time now is 04:31 AM.