Outils pour utilisateurs

Outils du site


issue151:tutoriel1

Ceci est une ancienne révision du document !


Welcome back! In this issue, we continue our automation journey. This part will be a short one as I need to break it into two pieces. If you have just joined us, we are automating things in Ubuntu. Last time, I asked you to open your menu with the mouse and click on your terminal to launch that. Did you manage to do it? If not, have a look at what I did.

My screen is 1600x 900, and my menu button for my Whisker Menu is in the top left. Though 0,0 is the topmost left spot, this does not open my menu, so I move the mouse slightly to 5,5. My menu also has its panels swapped around, so moving my mouse diagonally changes the menu layout as my mouse would move over different sections, changing the other panel. To overcome this, I first move my mouse slightly – onto the menu, then across, then down, before clicking on the terminal. (OR one could use key presses, but I wanted you to see a problem and fix a problem on your own). There are many ways to skin a cat in Linux, so if you did it another way, congratulations.

I know some of you have already figured out that this tool can be used for clicking in farmville or whatever clicker is the rage these days. That is good; it means you are applying a solution to a problem. We will look at this kind of thing in a later issue; for now, I want to get beginners to Ubuntu, or those of you who have not even heard of ‘xdotool’, up to speed. Obviously, I cannot imagine or show you every use case, we have only twelve issues per year. My goal is to spark your imagination and let your creative side take the reigns.

Up to now we have been using mousepad as an example. What if you do not know the name of the window you want to work with? That is where another tool comes in handy – wmctrl. Your homework: please go to the man page and look at the very first example. That’s what we will be doing to get the info on open windows. This will not only list windows, but panels and docks too, which is very handy. The number on the left is the window ID. This will be important later; for now, just know where to find it. Back to our journey. We have clicked the menu button, but we could also open it with a keyboard combination. (In my case, ctrl+esc on Xubuntu). We can even go directly to the terminal via the terminal shortcut ; whatever you set it to be in your system.

BUT WAIT, THERE'S MORE…

The ‘xdotool’ can be used to set up mouse gestures and hot corners on your XFCE system to behave like GNOME. Open a terminal and type: xdotool behave_screen_edge bottom-right exec /usr/bin/xfdashboard&

Now move your mouse to that corner and see. This is one way to test your code before you make your script. Now we can replace all that typing in our learning example with even less code - with what we have learned now.

xdotool behave_screen_edge top-left exec xfce4-popup-whiskermenu&

Now , moving the mouse to the top left corner, brings up the whisker menu. We can even automate that by moving the mouse with the command-line to 0,0, ( or the surrounds…).

The above examples are XFCE specific, but it will work on other DE’s - where your command does not conflict with an existing hot corner. Feel free to replace ‘xfdashboard’ with an application of your choice, as it was only meant to be an example of what is possible. You can now put these hot corner commands into a shell script and add it to your start-up list.

The beauty of ‘xdotool’ is that it also works over SSH, so if you need to do something repetitive, or automate some task on a remote computer, this is possible. We will delve into this in a future issue. You can also move and resize windows with this versatile tool; very handy if you use a tiling window manager (hint-hint). We will look at how to do this in the next issue.

If you have any suggestions or queries, please let us know. You can also send us your clever scripts of tweaks with ‘xdotool’, and we will make you famous! (Not quite, but it will get your name in print).

issue151/tutoriel1.1575118021.txt.gz · Dernière modification : 2019/11/30 13:47 de auntiee