<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kde on Hrishikesh Gohain</title><link>https://hrishikeshgohain.netlify.app/tags/kde/</link><description>Recent content in Kde on Hrishikesh Gohain</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 02 Mar 2026 23:00:00 +0630</lastBuildDate><atom:link href="https://hrishikeshgohain.netlify.app/tags/kde/index.xml" rel="self" type="application/rss+xml"/><item><title>SOK2026: Porting energy measurement scripts of KEcoLab to Wayland</title><link>https://hrishikeshgohain.netlify.app/posts/004.sok-midterm-update/</link><pubDate>Mon, 02 Mar 2026 23:00:00 +0630</pubDate><guid>https://hrishikeshgohain.netlify.app/posts/004.sok-midterm-update/</guid><description>&lt;h2 class="heading" id="about-me"&gt;
About me
&lt;a class="anchor" href="#about-me"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Hi Everyone ,I am Hrishikesh Gohain a third year undergraduate student in Computer Science &amp;amp; Engineering from India. For the past few weeks I have been working as a Season of KDE mentee with my mentors Joseph P. De Veaugh-Geiss ,Aakarsh MJ and Karanjot Singh.
This post summarizes the work I have done until Week 5.&lt;/p&gt;
&lt;h2 class="heading" id="about-kecolab"&gt;
About KEcoLab
&lt;a class="anchor" href="#about-kecolab"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://eco.kde.org/"&gt;KDE Eco&lt;/a&gt; is an ongoing initiative by the KDE Community that promotes the use and development of Free , Open Source and Sustainable Software. &lt;a href="https://invent.kde.org/sdk/kecolab"&gt;KEcoLab&lt;/a&gt; is a project that allows you to measure energy consumption of your software through ci/cd pipeline using a remote lab.It also generates a detailed report which can further be used to document and review the energy consumed when using one&amp;rsquo;s software and to obtain Blue Angel eco certification.&lt;/p&gt;
&lt;h2 class="heading" id="about-the-sok-project"&gt;
About the SOK Project
&lt;a class="anchor" href="#about-the-sok-project"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The Lab computer on which the software runs for testing was migrated to Fedora 43 recently, which comes with Wayland by default. Writing Standard Usage Scenario scripts, which are needed to emulate user behavior, was previously done with xdotool, but that will not work on Wayland. My work so far has been to port the existing test scripts to a Wayland-compatible tool. For those who want to contribute test scripts to measure their own software , the current scripts can be taken as a reference. My next tasks are to prepare new test scripts to measure energy usage of Plasma Desktop Environmen itself.&lt;/p&gt;
&lt;h2 class="heading" id="work-done-so-far"&gt;
Work done so Far
&lt;a class="anchor" href="#work-done-so-far"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 class="heading" id="week-1"&gt;
Week 1
&lt;a class="anchor" href="#week-1"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In the first week I studied the Lab architecture and how testing of software is done using KEcoLab. The work done by past mentees as part of SOK and GSoC was very helpful for my research which you can read &lt;a href="https://eco.kde.org/blog/2023-06-13-gsoc23-energy-measurement-lab/"&gt;here&lt;/a&gt; , &lt;a href="https://eco.kde.org/blog/"&gt;here&lt;/a&gt; and &lt;a href="https://eco.kde.org/categories/kde-eco/"&gt;here&lt;/a&gt;. I also set up access to the lab computers through SSH. RDP access had some issues which were solved with the help of my mentors. To replicate the lab environment locally, I set up a Fedora 43 Virtual Machine so that I can test scripts under the same Wayland environment as the lab PC.
I also documented and published a &lt;a href="https://hrishikeshgohain.netlify.app/posts/002.why-measure-software/"&gt;blog&lt;/a&gt; about the project and shared with my university community to promote the use of Free and Open Source Software and how it relates to sustainability.&lt;/p&gt;
&lt;h3 class="heading" id="week-2-and-week-3"&gt;
Week 2 and Week 3
&lt;a class="anchor" href="#week-2-and-week-3"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;I communicated with my mentors and other community members to decide the new wayland compatible tool. After evaluating different options, we decided to use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ydotool: for key press, mouse clicks and movements (works using the uinput subsystem)&lt;/li&gt;
&lt;li&gt;kdotool : for working with application windows (focusing, identifying window IDs, etc.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A combination of tools was required to meet all our requirements. To help future contributors, I published my first blog on Planet KDE explaining how to set up and use ydotool and kdotool . I also imported the repositories into KDE Invent for long term compatibility and wrote setup scripts for easier installation and configuration. These tools did not work out of the box and I had to make some workarounds and setup before usage which i documented in the blog.&lt;/p&gt;
&lt;h3 class="heading" id="week-4-and-week-5"&gt;
Week 4 and Week 5
&lt;a class="anchor" href="#week-4-and-week-5"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;During these weeks, along with my mentors, I installed and set up the required tools on the Lab PC. I then ported the test scripts of Okular from xdotool to ydotool and kdotool and did testing on my local machine first. Currently, the CI/CD infrastructure through which these scripts run on the Lab PC is temporarily broken due to the migration to Fedora 43. Once these issues are fixed, we will test the new Wayland compatible scripts on the actual lab hardware and compare the results with previous measurements.&lt;/p&gt;
&lt;h2 class="heading" id="next-steps"&gt;
Next Steps
&lt;a class="anchor" href="#next-steps"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;I will be working on measuring energy usage of Plasma Desktop Environment itself. It will be more challenging than measuring a normal software application because Plasma is not a single process. It is made up of multiple components such as KWin (compositor), plasmashell, background services, widgets, and system modules. All of these together form the desktop experience.&lt;/p&gt;
&lt;p&gt;Unlike normal applications like Okular or Kate, Plasma is always running in the background. So we cannot simply “open” and “close” it like a normal app. Because of this, some changes may be required in the current way of testing using KEcoLab.&lt;/p&gt;
&lt;p&gt;To properly design the Standard User Scenario (SUS) scripts for Plasma, I will discuss closely with my mentors and also seek feedback and suggestions from the Plasma community. Defining what should be considered a “standard” usage pattern will require careful discussion and community input.&lt;/p&gt;
&lt;h2 class="heading" id="lessons-learned"&gt;
Lessons learned
&lt;a class="anchor" href="#lessons-learned"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;It has been a very amazing journey till now. I learned how to make right choices of tools/software after properly understanding the requirements instead of directly starting implementation.&lt;/p&gt;
&lt;h2 class="heading" id="thank-you-note"&gt;
Thank You Note
&lt;a class="anchor" href="#thank-you-note"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;d like to take a moment to thank my mentors Aakarsh, Karanjot, and Joseph. I am also thankful to the KDE e.V. and the KDE community for supporting us new contributors in the incredible KDE project.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://invent.kde.org/sdk/kecolab"&gt;KEcoLab&lt;/a&gt; is hosted on Invent. Are you interested in contributing? You can join the Matrix channels &lt;a href="https://matrix.to/#/#kde-eco-dev:kde.org"&gt;Measurement Lab Development&lt;/a&gt; and &lt;a href="https://matrix.to/#/#kde-eco:kde.org"&gt;KDE Eco&lt;/a&gt; and introduce yourself.&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;</description></item><item><title>Write Standard User Scenerio Scripts to measure energy usage of software with KEcoLab</title><link>https://hrishikeshgohain.netlify.app/posts/003.how-to-do-automation/</link><pubDate>Fri, 06 Feb 2026 23:00:00 +0530</pubDate><guid>https://hrishikeshgohain.netlify.app/posts/003.how-to-do-automation/</guid><description>&lt;p&gt;KDE Eco is an ongoing initiative taken by the KDE community to support the development and adoption of sustainable Free &amp;amp; Open Source Software worldwide and I am happy to be able to contribute to this mission as part of Season of KDE 2026.&lt;/p&gt;
&lt;p&gt;As part of this initiative, KDE aims to measure the energy consumption of its software and eco-certify applications with the Blue Angel ecolabel. To make this possible, &lt;a href="https://invent.kde.org/sdk/kecolab"&gt;KEcoLab&lt;/a&gt; a dedicated lab based in Berlin provides remote access to energy-measurement hardware via a GitLab CI/CD pipeline to measure the energy usage of software following the guide documented in &lt;a href="https://eco.kde.org/handbook/"&gt;KDE Eco Handbook&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To measure energy usage of a software we need to prepare three scripts &lt;code&gt;baseline.sh&lt;/code&gt; , &lt;code&gt;idle.sh&lt;/code&gt; and &lt;code&gt;sus.sh&lt;/code&gt; and push them via MR to &lt;a href="https://invent.kde.org/sdk/kecolab"&gt;this&lt;/a&gt; repository, SUS or Standard User Scenario script emulates a standard user in a automated manner without human intervention, more on how to prepare SUS can be found &lt;a href="https://eco.kde.org/handbook/#preparing-the-standard-usage-scenario-sus"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Currently, these scripts rely on &lt;code&gt;xdotool&lt;/code&gt; to simulate user interactions. However, &lt;code&gt;xdotool&lt;/code&gt; does not work on Wayland. Since the KEcoLab computer have recently migrated to Fedora 43, which uses Wayland by default, the existing scripts no longer work.
To solve this problem,&lt;/p&gt;
&lt;p&gt;I am working with my mentors Joseph, Aakarsh, and Karanjot to port the existing test scripts from &lt;code&gt;xdotool&lt;/code&gt; to &lt;code&gt;ydotool&lt;/code&gt; and &lt;code&gt;kdotool&lt;/code&gt;, which are compatible with Wayland. As part of this effort, I’ve written a guide explaining how to use ydotool and kdotool more easily.&lt;/p&gt;
&lt;h2 class="heading" id="setup-ydotool-and-kdotool"&gt;
Setup &lt;code&gt;ydotool&lt;/code&gt; and &lt;code&gt;kdotool&lt;/code&gt;
&lt;a class="anchor" href="#setup-ydotool-and-kdotool"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To test the scripts you have written it&amp;rsquo;s recommended to setup locally.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: Some features changes and some are removed with updates so it&amp;rsquo;s recommended to build them from source mentioned here&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 class="heading" id="ydotool"&gt;
ydotool
&lt;a class="anchor" href="#ydotool"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Clone the repository and navigate into it&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; git clone -b feat/setup-script https://invent.kde.org/neogg/ydotool.git
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; ydotool &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Run the setup script&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chmod +x setup.sh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./setup.sh install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Give &lt;code&gt;ydotoold&lt;/code&gt; permission to uinput so it can run without root&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo touch /etc/udev/rules.d/99-uinput.rules
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;KERNEL==&amp;#34;uinput&amp;#34;, MODE=&amp;#34;0660&amp;#34;, GROUP=&amp;#34;input&amp;#34;&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; sudo tee /etc/udev/rules.d/99-uinput.rules &amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo usermod -aG input &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo udevadm control --reload-rules
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo udevadm trigger&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: A reboot (or full logout/login) is required for the &lt;code&gt;input&lt;/code&gt; group change to take effect.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ol start="4"&gt;
&lt;li&gt;Reboot your computer and run&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;systemctl --user start ydotoold&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;Verify that you can use ydotool by &lt;code&gt;ydotool type &amp;quot;Hello&amp;quot;&lt;/code&gt; you will see Hello typed if installation was successful.&lt;/p&gt;
&lt;h3 class="heading" id="kdotool"&gt;
kdotool
&lt;a class="anchor" href="#kdotool"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Clone the repository and navigate into it&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; git clone -b feat/setup-script https://invent.kde.org/neogg/kdotool.git
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; kdotool &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Run the setup script&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code-block"&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;chmod +x setup.sh
./setup.sh install&lt;/code&gt;&lt;/pre&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;Verify that you can use kdotool by &lt;code&gt;kdotool -h&lt;/code&gt;&lt;/p&gt;
&lt;h2 class="heading" id="how-to-use-ydotool-and-kdotool-to-perform-various-actions"&gt;
How to use ydotool and kdotool to perform various actions
&lt;a class="anchor" href="#how-to-use-ydotool-and-kdotool-to-perform-various-actions"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 class="heading" id="press-keys"&gt;
Press keys
&lt;a class="anchor" href="#press-keys"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For pressing keys we use ydotool , the syntax for pressing keys is a little confusing when you look at it :&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool key KEY_CODE:ACTION&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;KEY_CODE&lt;/p&gt;
&lt;p&gt;Linux uses a file named &lt;code&gt;input-event-codes.h&lt;/code&gt; that defines numeric codes for everything an input device can generate in Linux. Simply speaking for every type of keypress there is a numerical representation. For example, the LEFTCTRL key is represented by 29, and the letter T is represented by 20.
How to find the code for the key you want to press , You can read the original &lt;code&gt;.h&lt;/code&gt; file by &lt;code&gt;nano /usr/include/linux/input-event-codes.h&lt;/code&gt; if you are in a linux system ( i hope you are using one). or inspect the file &lt;a href="https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I use grep to find the code for the key i want since the header file is too long &lt;code&gt;grep KEY_LEFTCTRL /usr/include/linux/input-event-codes.h&lt;/code&gt; and so on.&lt;/p&gt;
&lt;p&gt;ACTION&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1 : key is pressed&lt;/li&gt;
&lt;li&gt;0 : key is released&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So to press and release &lt;code&gt;Ctrl&lt;/code&gt; you can use the following command&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool key 29:1 29:0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;h3 class="heading" id="press-key-combinations"&gt;
Press key combinations
&lt;a class="anchor" href="#press-key-combinations"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Key combinations is the same as above , you just need to keep all the keys pressed.
So to press &lt;code&gt;Ctrl+Alt+T&lt;/code&gt; which opens up a terminal you can use the following command&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool key 29:1 56:1 20:1 29:0 56:0 20:0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;This translates to Ctrl(pressed) Alt(pressed) T(pressed) Ctrl(released) Alt(released) T(released)&lt;/p&gt;
&lt;p&gt;This will hopefully open up a terminal.&lt;/p&gt;
&lt;h3 class="heading" id="click--left-right-double"&gt;
Click ( left, right, double)
&lt;a class="anchor" href="#click--left-right-double"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For performing mouse clicks we can use the click command in ydotool , If you are do not like codes unlike me,I am sorry but again we have codes&amp;hellip;&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click OPTIONS BUTTON_CODE&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;OPTIONS&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--repeat&lt;span class="o"&gt;=&lt;/span&gt;N : can be used to press a button N &lt;span class="nb"&gt;times&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--P : can be used to press and release a button as that&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;s what we mostly &lt;span class="k"&gt;do&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;BUTTON_CODE&lt;/p&gt;
&lt;p&gt;This is a hexadecimal value that represents different mouse buttons (left, right, middle, etc.).&lt;br&gt;
Yes, it looks ugly at first, but you can always open up my blog.&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0xC0 &lt;span class="c1"&gt;# left click&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0xC1 &lt;span class="c1"&gt;# right click&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0xC2 &lt;span class="c1"&gt;# middle button click (scroll button)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x40 &lt;span class="c1"&gt;# left button down (press)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x80 &lt;span class="c1"&gt;# left button up (release)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x41 &lt;span class="c1"&gt;# right button down (press)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x81 &lt;span class="c1"&gt;# right button up (release)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;And some combinations
This can be useful to select text, drag and drop etc..&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x40 &lt;span class="c1"&gt;# left down &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove &lt;span class="m"&gt;300&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="c1"&gt;# drag right &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt; &lt;span class="c1"&gt;# drag down &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x80 &lt;span class="c1"&gt;# left up&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;same as above but more reliable with delays to simulate a real user&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x40
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove -D &lt;span class="m"&gt;20&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove -D &lt;span class="m"&gt;20&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool click 0x80&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;h3 class="heading" id="type-text"&gt;
Type text
&lt;a class="anchor" href="#type-text"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Typing text is pretty simple using ydotool&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;string-you-want-to-type&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;h3 class="heading" id="focus-a-specific-app"&gt;
Focus a specific app
&lt;a class="anchor" href="#focus-a-specific-app"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kdotool search --name &lt;span class="s2"&gt;&amp;#34;Window Title&amp;#34;&lt;/span&gt; windowactivate
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kdotool search --class appname windowactivate
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kdotool search --classname org.kde.app windowactivate &lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; kde apps &lt;span class="o"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;h3 class="heading" id="send-mouse-and-keyboard-commands-to-a-specific-window"&gt;
Send mouse and keyboard commands to a specific window
&lt;a class="anchor" href="#send-mouse-and-keyboard-commands-to-a-specific-window"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Focus the window using kdotool than execute commands using ydotool since commands are always executed in the active window.&lt;/p&gt;
&lt;h3 class="heading" id="get-current-mouse-location"&gt;
Get current mouse location
&lt;a class="anchor" href="#get-current-mouse-location"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We can use kdotool for getting the current mouse location which also returns the windowID along with x and y coordinate of current mouse location&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kdotool getmouselocation&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;The output :&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;x:42 y:96 screen:0 window:&lt;span class="o"&gt;{&lt;/span&gt;e8aeec46-5c45-42cc-9839-8ad2edcb7f4f&lt;span class="o"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;If you only want to extract the x and y value since thats what&amp;rsquo;s more important you can do that using regex&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Read mouse location&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;loc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;kdotool getmouselocation&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Extract x and y&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$loc&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; sed -n &lt;span class="s1"&gt;&amp;#39;s/.*x:\([0-9-]*\).*/\1/p&amp;#39;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$loc&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; sed -n &lt;span class="s1"&gt;&amp;#39;s/.*y:\([0-9-]*\).*/\1/p&amp;#39;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;h3 class="heading" id="move-mouse-to-a-specific-coordinate"&gt;
Move mouse to a specific coordinate
&lt;a class="anchor" href="#move-mouse-to-a-specific-coordinate"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Note : We can use ydotool to move the mouse but that may not give us any visual feedback if you are using it in a VM, that is you cannot see the actual mouse cursor move when the commands are executed but you can use the &lt;code&gt;kdotool getmouselocation&lt;/code&gt; to see how the mouse location gets updated.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There is a command in ydotool&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove --absolute -x x-value -y y-value&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;but that does not work in Wayland properly.&lt;/p&gt;
&lt;p&gt;We have an another command that moves the mouse relative to current mouse location so we can use that.&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove -x x-value -y y-value&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;mousemove -9999 -9999 ( moves the mouse to top left 0,0)&lt;/li&gt;
&lt;li&gt;mousemove x y ( now we move relative to 0,0 so that&amp;rsquo;s like absolute mousemove)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 class="heading" id="move-mouse-inside-a-specific-window"&gt;
Move mouse inside a specific window
&lt;a class="anchor" href="#move-mouse-inside-a-specific-window"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Since we cannot directly send mouse events to a window on Wayland, we rely on window geometry that we can get using kdotool and do relative mouse movement using ydotool.&lt;/p&gt;
&lt;p&gt;The steps are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Focus the window&lt;/li&gt;
&lt;li&gt;Get the window geometry&lt;/li&gt;
&lt;li&gt;Reset the mouse to &lt;code&gt;(0,0)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Move the mouse relatively using the window coordinates&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# First, focus the window:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kdotool search --class firefox windowactivate
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Get the window geometry:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kdotool search --class firefox getwindowgeometry
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Example output:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Window {a24d3d34-85f6-4915-821b-54a71a959f6a}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Position: 340.23748404968967,68.49159882293117&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Geometry: 768x864&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;#Reset the mouse position to the top-left corner of the screen:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove -x -9999 -y -9999
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Move the mouse to the Position you got from above command (top left corner of the window )&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Now move the mouse inside the window (top-left corner of the window):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove -x &lt;span class="m"&gt;120&lt;/span&gt; -y &lt;span class="m"&gt;80&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;#At this point, the mouse cursor is inside the target window. so you can now move inside the window , but only once than again repeat the above steps once again ( i will think of a script to automate this)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;h3 class="heading" id="move-mouse-to-the-center-of-a-window"&gt;
Move mouse to the center of a window
&lt;a class="anchor" href="#move-mouse-to-the-center-of-a-window"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Moving to the center of a window uses the same idea, but instead of moving to x and y, we add half the width and height.&lt;/p&gt;
&lt;p&gt;From the geometry we extract :
x=120
y=80
width=1280
height=800&lt;/p&gt;
&lt;p&gt;Calculate the center:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;center_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; x + width / &lt;span class="m"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;center_y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; y + height / &lt;span class="m"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;Reset the mouse again:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove -x -9999 -y -9999&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;Move the mouse to the center of the window:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ydotool mousemove -x center_x -y center_y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;button class="copy-code-button"&gt;copy&lt;/button&gt;
&lt;/div&gt;
&lt;p&gt;These completes all the basic actions that are required to automate user actions , We may need to combine many of above to do tasks that simulate real user.&lt;/p&gt;</description></item></channel></rss>