Episode: 1814 Title: HPR1814: Custom Context Menus in GNU/Linux GUI File Managers Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1814/hpr1814.mp3 Transcribed: 2025-10-18 09:38:42 --- This is HPR episode 1,814 entitled Custom Context Menu in GNU Sashlinux GUI File Manager. It is hosted by John Culp and is about 13 minutes long. The summary is, I describe how to add Custom Context Menu items in the Nautilus and the file manager. This episode of HPR is brought to you by an honesthost.com. At 15% discount on all shared hosting with the offer code HPR15, that's HPR15. Better web hosting that's honest and fair at An Honesthost.com. Hey everybody, this is John Culp and Lafayette Louisiana and today I'm going to do a fairly quick episode about how to add custom actions and run custom scripts and so forth from Linux GUI File Managers. This is something I don't remember exactly when I discovered this but I remember it was one of those aha moments where I thought, wow, this is one of the great things about running on a GNU Linux system. What I'm talking about here is when you're looking around in a GUI File Manager but the one I use by default is Thunar. I run a Debian system with OpenBox Window Manager and Thunar is the default File Manager on here. What you can do is set up a context menu where you can right click on one of your files and run a custom action on it. In other words, you don't have to be limited to what the default context menu items are. And you can do, actually, I had never even tried this on Nautilus which is the default Nome Desktop File Manager until this morning but I thought if I were going to do this episode I should probably at least give the basics on how to do it on those two File Managers which I think are the most commonly used File Managers on the GNU Linux Desktop. On Nautilus it seems to me it's not quite as elegant and you don't have quite as much power but it is possible to do what you need to do. What you have to do is go into a special Nautilus Script folder which on my system is located in the home directory in the .local slash share slash Nautilus slash scripts directory. And you can either put your scripts in there or you can do like I prefer to do and that is to make symbolic links to your scripts in there. Otherwise if you just put copies of your scripts in there then if you change the script I'm assuming if you are somebody who writes a lot of scripts then you probably put them in your slash home slash bin directory so that they will be in your path and I do not really want to move the scripts out there or have duplicate copies anywhere because if you edit the script and you forget to copy it over into your Nautilus scripts folder then when you run that script from the context menu on your File Manager you won't have the latest version of the script so for me it seems like a better practice to put a Simlink to your only have one copy of the script I don't like having duplicate files around on the system. So anyway once you have put the Simlinks or scripts in the Nautilus Scripts directory then when you right click on a file in the Nautilus File Manager you go down to where it says scripts and then that opens out to a side menu and you just choose whichever script it is that you want to run on that file and that works okay I tried it on a couple of things this morning and it worked just fine. On a Thuner you don't have to put your scripts anywhere special you actually can put a full path to the script when you're setting up the custom action I actually like it much much better on Thuner the way it handles this whole thing. What you do is from inside the Thuner File Manager you go to the Edit menu and then choose to configure custom actions and then you'll see some actions there already that were set up by default and if you want to add your own custom action you click on the plus button which if you hover over it it says add a new custom action and then you'll have a dialog box with two tabs on it the first tab is called Basic and that is where you can give your custom action a name then you can give it a description and I think I normally just leave that blank and then in the third line you can set the command that is to be run when this thing is chosen from the context menu. They give you a little tip there at the bottom that says the following command parameters will be substituted when launching the action. If you want the script to be run on the first selected file which is I don't think I have any of them that do anything besides that but you use a percent sign F that will so you put the command followed by a space followed by percent F and that will make it so that when you choose that action when right clicking on a file it will run your script on that file with that file as the first command line argument. Other options are to use a capital F instead of the lowercase F and that is supposed to run it on all of the selected files and it seems like I tried that once and was not successful and I don't know why and didn't really feel like digging any deeper to figure out what was wrong. You can also run a script on an entire directory or multiple directories and so forth. So on the second tab that is the appearance conditions and to me this is where it gets a little bit more powerful than what you get on Nautilus where you have to see essentially all of the scripts that you want to be able to run on any files up here every time you right click on something Nautilus whereas here you can set up appearance conditions. So for example a couple of my scripts have to do with manipulation of images like I want to take the selected image and reduce its width to 300 pixels and so I will check the little box here that says appears if selection contains image files. I'll check the image files and I'll uncheck the text file so that anytime I right click on an image file this custom script is one of my options whereas whereas if I right click on a text file that script does not appear because it's not appropriate to try to run an image conversion script on a text file. You can also instead of checking these rather general category boxes here you can give a file pattern and so sometimes I will do something like a asterisk.ly if I want this option to appear only when I right click on a lilypon source file. So it's it's pretty cool. The the kinds of scripts that I have here I want to say I've got let's see one two three four five I've got about 10 of these custom actions one of them I don't know if I've used in a while it says post photo to pump.io that would be my one of my social networks and so if I right click on an image and choose to post it to pump.io it runs a script that will post that image to my timeline there. That's kind of cool I remember using it for a while but I think it might have been one of those things where I was just trying it to see whether it would work or not. I have another one that I call markdown this and if I right click on a markdown source file and choose this it will run the markdown command on it to create an HTML file from it. I have another one that says fix audio with Alphonic. Alphonic is a it's a web-based audio cleanup tool it does various you know it will apply various filters to your audio things like compression and amplification and whatnot to try to make it sound as good as possible and it actually works pretty well if you are an HPR contributor and would like for your audio to sound better like it not to be so quiet or something and you're not really sure how to do this in audacity then you might consider trying Alphonic I think it's Alphonic.com I'll I'll put a link in the show notes just for the heck of it but you can just upload a file and tell it in general terms what you want done and it'll run a conversion script and actually it works pretty well then I have a few image conversion scripts that I have custom actions configured for if I want to make an image 600 pixels wide 300 to 50 I use these a lot when I was developing the School of Music website because I wanted the images all to have certain widths then I have another one to build a web page for my website I have my I have a certain build script that I run on a source file for a web page and I can right click on that file and it'll build the page then I have a couple of things related to my counterpoint book and I actually added one called Gimpit and I did this because it seemed like I was tired of going to levels deep to choose Gimp to open up an image but I didn't necessarily want to make Gimp the default thing for opening up an image most of the time I just want to view the image and on my system that would open up VUNY or which is just a little image viewer but I added a custom command to run Gimp on an image so that it would be available on the first level of my context menu and one thing that I used on this that I didn't on did not on any of the others is I put an underscore on the like before the G in the word Gimp this is something that you do in the name the hang on let me look again the name on the first tab on the create action thing under name if you put underscore GIMP then when you right click on an image file the G will be a hotkey and then you can just press the G key and it will select that item it'll have like a little underscore under the G let's see I had two more one is to remove spaces in a file name and I think when I right click so if I download a file that one of my colleagues sends me I never have any spaces in my own file names but people who send me stuff almost always have spaces and if I have to do any kind of work with the file then I want to remove those spaces so I can right click on the file in my file manager choose this and it will replace all the spaces with underscores and then the last one that I have configured is add to caliber library and if I right click on an e-pub file or an easy w3 file it will run one of those command line caliber Python things and add it to my caliber library so anyway that's that's about it I if you use Thunar especially I definitely encourage you to try this out especially if you write a lot of your own scripts and are frequently running them on files a lot of times you'll just want to run them from the command line but it can be handy to be able to do it by just right clicking inside a graphical file manager as well right I think that's it I will talk to you all later bye you've been listening to Hacker Public Radio at Hacker Public Radio dot org we are a community podcast network that releases shows every weekday Monday through Friday today's show like all our shows was contributed by an hbr listener like yourself if you ever thought of recording a podcast and click on our contributing to find out how easy it really is Hacker Public Radio was founded by the digital dog pound and the infonomicon computer club and it's part of the binary revolution at binrev.com if you have comments on today's show please email the host directly leave a comment on the website or record a follow up episode yourself unless otherwise stated today's show is released on the creative comments attribution share shout out you