Xfce

Subdomains
 

GSoC’22: The Final Report

  • September 19, 2022
  • Yogesh Kaushik

My days as a GSoC mentee have ended, and I would like to share everything I have done during these days and what is left. I have posted a few blogs already, so if you have read them, you already know what I have done, and thus you can skip to the last section.

Thunar

(MR #267)

The Bulk Renamer, although very well functional, had a flaw. In case of a new name for a file matches the original name of a file that is yet to be renamed, then the Bulk Renamer used to fail. But now, I have modified it so that it can resolve any such kind of dependencies.

This new enhancement has been successfully added to the Thunar. More details about how this enhancement is added can be found in my blog (GSoC'22: Making Thunar Bulk Renamer More Advanced)

Screenshooter

(MR #37)

Screenshooter had some predefined options that users could choose from once the screenshot was taken. But now, the user can execute a custom action. This new feature has been successfully added to the Screenshooter and tested quite well. More details about this can be found in my blog (GSoC'22: Adding Custom Actions to Screenshooter)

Panel Plug-in

(MR #101) (MR #99)

Panel had an external plug-in Date Time and an internal plug-in Clock. These two plug-ins were somewhat overlapping, and now all the features of these plug-ins are merged into the Clock plug-in. The clock plug-in can now show the date and the time, and the font is also customizable. This merge is almost completed and is just left for the final reviews. Pretty soon, it will be present in Panel 4.17.4.

The Future

An extended goal was proposed to add command line support for the custom actions. Even though my coding period under GSoC is ending, I wish to complete that extended goal to make the custom actions feature more accessible for the users.

GSoC’22: Adding Custom Actions to Screenshooter

  • September 17, 2022
  • Yogesh Kaushik

The Task

Screenshooter (xfce4-screenshooter), as the name suggests, is an application that takes screenshots. Some action is needed once the screenshot is taken on the captured image. Currently, the application provides four well-defined actions: to save the picture, open the image, copy it into the clipboard, and upload it to Imgur. But some users may want to perform other specific actions after taking the screenshot, such as printing them or sending them over an email. So the task was to allow users to add custom actions that can be executed once the screenshot is taken. Similar functionalities are also present in Thunar and AppFinder.

The Solution

The solution was quite simple. We can have a list of user-defined custom actions stored in the system. Each element in the list will denote a custom action and will have attributes "name" and "command". The "name" attribute stores the string that will be displayed to the user when selecting the custom action. And the "command" attribute is the command that will be executed. The command can have a '%f' placeholder that can be used to get the absolute path of the screenshot captured. For storing this list, xfconf was used. Each custom action has a unique id associated with it. So if that unique id for a custom action is 'i' then its attributes are stored as "actions/action-i/name" and "actions/action-i/command". The rest of the solution includes providing a simple user interface to modify this list and executing the command.

Under The Hood

With the help of my mentor, André Miranda (AndreLDM), this solution was successfully implemented in MR #37.

The first part of implementation involves creating a preferences dialog box that can be used to modify the list of custom actions. It must be noted that whenever the dialog box opens, it reads the data from the hard disk, and whenever it closes it stores the data back into the disk. This dialog box allows users to add, delete and modify custom actions.

The next part was to add an option for selecting a custom action to be executed once the screenshot was taken. Here again, the list of custom actions is read from the system, but it is never written back as no modifications are done to it. This option is only shown if there are custom actions in the list. If, instead, the list is empty, then this option is not offered. Once the user selects the custom action, its name and command are stored in the ScreenshotData structure.

Then comes the most crucial part, where the custom action gets executed. Here we don't read the list, just the command and name stored in the ScreenshotData structure. The absolute path of the image first replaces the placeholder text. Then "g_spawn_async" is used to execute the command asynchronously. It's done asynchronously so that the command may not block the application.

This implementation's beauty lies in how we have used the already implemented code. Once the image is captured, it is stored in the /tmp directory using the "Save" option. Then the execution part happens. So under the hood, two actions are occurring from the action selection dialog box.

GSoC’22: Making Thunar Bulk Renamer More Advanced.

  • July 10, 2022
  • Yogesh Kaushik

The Task

Most of you would be aware of bulk renamer, a handy plugin in Thunar to rename many files together. The plugin is already very advanced and can perform many complex tasks. But sometimes, performing those tasks required more user interference than expected. Consider a case where you are renaming two files, and the new name for one file matches the old name of the second file. Now, no issue arises if the second file is renamed first, and the bulk renamer works perfectly. But if the first file is renamed, it throws an error message as the filename already exists. In the case of two files, the user can resolve such errors manually, but it can become a very tedious task for a large number of files. So the job was to make the bulk renamer intelligent enough to identify the best order in which the files should be renamed so that all such errors are resolved entirely. A trivial usage case for it

is to be able to rename files named file4, file5 ... file13 to file1, file2 ... file10.

The Solution

Sorting is a critical player in the entire solution. The bulk renamer now tries three runs to rename a file. In the first run, the files are renamed in the user-specified order. If some files are not renamed successfully in this run, then the bulk renamer moves for the second run. Before starting the second run, all the failed files are first sorted in ascending order according to their current name. And then it tries to rename them again. But if still some files fail, it moves to the third run. Here the files are first sorted in reverse order and then renamed. The user is shown an error message if a file is still falling.

Under The Hood

With the support of Thunar's lead developers Alexander Schwinn (alexxcons), Sergios - Anestis Kefalidis and Yongha Hwang (MShrimp4), the solution is implemented successfully. Implementing the three runs and sorting was not much of a big deal. But the real deal was to manage all the other systems that broke down due to the changes. One of the noteworthy was the undo option. But after rigorous manual testing, the entire system is working correctly and ready to be used by general users. I hope this advancement will highly benefit the users.

With this done, it's time for me to move on to my task for Xfce-Screenshooter.

GSoC’22: The Journey Begins

  • May 26, 2022
  • Yogesh Kaushik

I am pleased to inform you that my proposal for GSoC with Xfce, under the mentorship of André Miranda, has been accepted. So this summer, I will be contributing to Xfce. Allow me to introduce myself and the work that I will be doing.

I am Yogesh Kaushik, a sophomore at IIIT Delhi in the Computer Science Engineering branch. As per the suggestions of a few intelligent souls in my college, I dual-booted my system and began using Linux for regular use in my first semester of college. My first Linux distribution was Kali, and that's how I was introduced to Xfce. Over time, I also tried quite a few other desktop environments like KDE and GNOME. But for me, the simplicity of Xfce is simply unmatched. So when I got the opportunity to contribute to it, I can't refuse it. Luckily the opportunity didn't turn me down. Enough of my introduction; let me now tell you about my objectives for GSoC this year.

Thunar Bulk Renamer

Thunar is the file manager for Xfce. It comes with fascinating support for renaming multiple files, and that feature is called Bulk Renamer. The Bulk Renamer itself is a very advanced feature, but it may require unnecessary human intervention under some circumstances. If the user wants to rename a file, such that the new name is the original name of some other file, which is yet to be renamed, the system will require user interference. For more clarity, let's say the user wants to rename a file as "File02", but there is already a file named "File02," which is already added to the Bulk Renamer but is yet to be renamed. In such a situation, the Bulk Renamer will raise an error and ask the user to fix it manually. My task would be to make the Bulk Renamer intelligent enough to identify such situations and allow it to act independently in such cases.

This would be my first task in GSoC, so how I am going to do that, you will see quite soon.

Screenshooter

As the name suggests, it is an application to take screenshots in Xfce. The application is exceptionally rich in terms of the functionalities it currently has. And my task would be to make it even more prosperous. I would introduce the support for custom actions in the Screenshooter. For those of you who would have used Xfce a lot, you must have seen the custom actions in Thunar or AppFinder. For those who don't know it, allow me to elaborate. With the help of custom actions, the user will be able to run custom scripts for the taken screenshot. So if you want to directly upload your screenshot to your favorite hosting platform, you just need to create one script, and that's it; you are good to go. Similarly, you can do a lot more with it.

Panel

Xfce Panel is where you can find your open apps and a lot of widgets. Depending upon your Linux Distro, you can find it on any four sides. Generally, for Kali, it is present on the top. But you can customize it according to your own choices. Now panel has a lot of plugin, some of which are internal and some are external. My task would be to merge two such plugins, namely "DateTime" and "Clock". The two plugins are very similar and thus they should be merged for better developments in future.

If the time permits I will do a few more enhancements in the Xfce environment. My journey with Xfce has started and I hope it will go smoothly even beyond the scope of GSoC.

Congratulations to fellow Xfce GSoC contributors Pratyaksh Gautam and Amrit Borah.