Jump to content

Photo

Help with Script or other solution?

Scripts

  • Please log in to reply
3 replies to this topic

#1 Randy

Randy

    Bodhi-Care

  • Members
  • 589 posts
  • LocationFort Wayne, IN USA

Posted 20 August 2016 - 04:42 PM

Hi,

 

In my spare time I like entertaining myself by manipulating the LXDE desktop. Right now I'm working on a mimic of the Unity desktop. A few screenshots...

 

SERVICE='lxlauncher'
 
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    pkill lxlauncher &&
    wmctrl -k off &
else
    wmctrl -k on &
lxlauncher &
#transset -n lxlauncher .65 &
sleep 60 &&
pkill lxlauncher &&
wmctrl -k off &
fia4fA4Uc.png

 

77PMePM.png

 

 

IAuteol.png

 

 

 

v8FDcRb.png

 

 

 

 

The problem. LXDE has a launcher called lxlauncher which is really just a graphical menu. It is ment to be a desktop itself. But using a script I was able to use it for a mimic of the Unity Launcher, almost! I have a scripts that toggles it on and off and after a set time makes it disappear.

 

But I was wondering if there was a way to make it work like a normal menu as far as the mouse is concerned. Basically when you click on an application inside of it, the application starts but of course the launcher remains until I click on the button in the panel or the script times out.

 

Does anyone know of a way to make it disappear when you click off of it or click on an application in it (make it work like a normal menu), by doctoring my script or another solution?

 

Here is the text of my script and I'm no script kiddy ...

SERVICE='lxlauncher'
 
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    pkill lxlauncher &&
    wmctrl -k off &
else
    wmctrl -k on &
lxlauncher &
#transset -n lxlauncher .65 &
sleep 60 &&
pkill lxlauncher &&
wmctrl -k off &
fi

Randy Fry



Linux Addict!



A big thank you to everyone who contributes to Bodhi Linux


#2 staind

staind

    Member

  • Banned
  • 132 posts

Posted 20 August 2016 - 06:38 PM

If i remember wmctrl correctly, before you issue the command you should bring the right window into focus, as if you clicked on it. In your script above, you have wmctrl -k but which one is going to receive that command? That is, which window has the focus? man wmctrl in a terminal will provide the online manual.

 

Not all the commands should end in '&'; That is why it's not acting like a menu at all! Think of it this way, if I were the program, I am putting up a screen. Normally, the user has to make a choice when he sees the screen. But the ampersand (&) at the end is telling the program to disregard the input--any input such as ESC or mouseclick--and move on to the next instruction. This is like saying run the rest of the program with or without any user input. You simply need to remove the excess ampersands, take out the unnecessary pkills, and your script will start behaving properly.

 

To help you decide which of them need to go, normally the ampersand goes with the action that the menu option will perform (the input has been accepted and processed already), as a general rule.

 

There are alternatives like zenity that display messages with 'OK' and 'Cancel', if you want to be thorough with testing with screens. For menus I try them out with bash and wmctrl, but then I use wmctrl with the window id parameter, but that's me.


In case you have a hard time choosing a shirt, pick the black one with the words "Bodhi Linux" on it.

#3 Randy

Randy

    Bodhi-Care

  • Members
  • 589 posts
  • LocationFort Wayne, IN USA

Posted 21 August 2016 - 02:46 AM

It's a mess isn't it? But it works as a toggle script. The wmctrl -k command just minimizes all open windows.  So in short the program I'm controlling is called lxlauncher. The script as is, is basically an on/off switch called by a .desktop file. So when you click the desktop file it calls this script. This scripts call lxlauncher if it's not on, minimizes all open windows, pauses for 1 minutes to give the user time to browse the menu, then kills lxlauncher and restores the open windows.

 

Thanks for the tips. I'll try to clean it up. 

 

The lxlauncher is just a tabed graphical menu. It's not meant to be used as a open and close type menu, but is supposed to be a combination menu/desktop. It doesn't  have normal window borders or a titlebar. So i'm not using it for it's intended purpose.

 

That being said,  I added the .desktop file that activates the script to the panel as a launcher. So when I click on it, it activates the script that turns on the lxlauncher. If I click it again it turns it off., Or I can just wait 60 seconds and it will turn off.

 

I'm trying to find some way to make it disappear when you click off of it with the mouse or click on an application in it. The bottom 2 screenshots above show the lxlauncher. I'm probably out of luck, but I thought I'd check around to see if anyone had any ideas.


Randy Fry



Linux Addict!

#4 staind

staind

    Member

  • Banned
  • 132 posts

Posted 21 August 2016 - 01:00 PM

What we are trying to do is, "make it disappear", whatever "it" is. Wmctrl can retrieve the window id of whatever's on top of the stack. (Warning: this may get a bit technical.) Get that id, save it (you need not know the specific value--the script just needs to remember or store it), then minimize that or get it out of the way. But your seemingly casual use of wmctrl -k here and there is the equivalent of a program saying "Whatever; nuke em all" when the display's the main thing; it's an interactive thing. It's like flying blind all of a sudden, and you just left it on autopilot.

 

Do a bit of code cleanup; we can take it from the better-looking remains.

 

Now that you've described what it is, well, I could be off-track in making it work like something it's not--a normal screen. Try a little cleanup and test that version. You may want to hang in the channels the lxdevs are in, and toss them a couple of questions or so.


In case you have a hard time choosing a shirt, pick the black one with the words "Bodhi Linux" on it.





Also tagged with one or more of these keywords: Scripts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users