Dragster...


Dragster...

Lately i found my self, looking for ways to make stuff more quickly. One way, for sure is the terminal, but still not everything can be done with a terminal and sometimes is quicker to drag'n'drop something, somewhere, than open a terminal cd to a directory and execute a command. Even with GUI apps ex. file manager, doing stuff, may need many clicks to finally do something, that you may be doing many times in the day.

So... here it is... Dragster! It's a small PyQt5 program, that combines GUI and "terminal logic" to quickly perform, everyday stuff, that you do on your computer. For example, i always send files to other devices i have, via email. So instead of opening the mail program, creating an email... blah.. blah... blah... i just drag'n'drop a file to Dragster, select the action i want and done, with just two movements. For sure, it needs some customization in the beginning, but after that, i think that you will earn much more time, that you would spent on making the same things, over and over.

You could use Dragster as it is. I have included some basic actions, but the whole magic is to customize it to your needs. The default actions are there to give you some ideas and see how it works. Dragster supports actions, which are based on two simple categories, files and text. In each action, you can use code tags, to customize the action and give you some flexibility. The code tags, are there just for simplicity. The same functionality, could be achieved, by using scripts, but then you would find your self, creating many scripts, scattered on your system perhaps. So, you can use the code tags to make things more simply. Let's see them.

Code Tags for Files
  • :file: This will pass the complete filename and path, as it was dragged on to the app.
  • :fname:: This will pass only the filename, with out the extension
  • :fext:: This will pass only the file extension
  • :fdir:: This will pass the path of the file, without the file name.
Code Tags for Text
  • :text:: This will pass the whole text/string, dragged on to the app.
Common Tags
  • :timestamp:: Will insert a date-time string like: 20250120-194423
  • :year:: Inserts the year like: 2025
  • :month:: Inserts the month like: 01
  • :day:: Inserts the day like: 12
  • :time: Inserts the time like: 194423
  • :home:: Inserts the home path/dir. of the current user ex: /user/me
  • :user:: Inserts the username of the logged user

Parameters

Dragster, accepts also two parameters. One for setting a different settings file and one for custom actions. This way, if you wanted, you could use multiple instances of the program or load custom actions depending the usage. The usage is like this:

-s <settings_file>, --settings <settings_file>
                        Specify settings.json file
  -a <action_file>, --actions <action_file>
                        Specify actions.json file

Custom Actions

Below are some ideas i have to use the program. It may give you inspiration to make yours. If you have a good one, please share it.

Send Attachment file with Evolution

{'name':'eMail File (Evolution)','command':'evolution mailto:\?attach=":file:"','type':'file'}

Send Attachment file with Thunderbird

{'name':'eMail File (Thunderbird)','command':'thunderbird -compose attachment=":file:"','type':'file'}

Open in Browser

{'name':'Open in Browser','command':':browser: ":url:"','type':'url'}

Add a Separator in the Menu

{'name':'','command':'','type':'separator'}

Open a file, with the associated program

{'name':'Open File','command':'xdg-open ":file:"','type':'file'}

Convert a Youtube video to MP3

{'name':'Video to MP3','command':'yt-dlp -R5 -c --extract-audio --audio-format=mp3 -P "/home/:user:/Music" ":url:"','type':'url'}

Compress and backup a file to a location

{'name':'Backup File','command':'zip /home/:user:/:fname:.zip ":file:" -j','type':'file'}

Copy a file to a remote server

{'name':'Copy to Server','command':'scp ":file:" :user:@192.168.1.5:/home/:user:/:fname:.:fext:','type':'file'}

Error reporting...

To know that a command was ended successful, you can add the following at the end of each command:

&& notify-send -i evolution "Evolution" "Mail Sent" || notify-send -i dialog-error "Evolution" "Email Failed!" -u critical

It uses notify-send to create a notification, with a message and icon. Adding the above string, will show a message either if the command we tried to execute was successful or not, with the appropriate message and icon. So, for the Evolution action from above the complete command would be:

evolution mailto:\?attach=":file:" && notify-send -i evolution "Evolution" "Mail Sent" || notify-send -i dialog-error "Evolution" "Email Failed!" -u critical

Using scripts...

Because the above command got too big... we can put it in a script and then add the script, in the action. So the script we would use, would be like:

#!/usr/bin/bash
evolution mailto:\?attach="$1" && notify-send -i evolution "Evolution" "Mail Sent" || notify-send -i dialog-error "Evolution" "Email Failed!" -u critical

...and the Dragster action would turn to be like:

{'name':'eMail File (Evolution)','command':'/path/to/script.sh ":file:"','type':'file'}

You should use absolute paths to be sure.

Add a comment

Previous Next