this post was submitted on 22 Dec 2024
39 points (89.8% liked)

Linux

48878 readers
1234 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I want code to right click context menu on a file and if it is a .mp4, then convert that to a .mp3 of the same name

also include an option to play faster by +25 +33 +50 or slower by -25 -33 -50 (in a sub menu)

I understand this is different depending on your system, so answer how to do it for the people who use the same system as you

top 26 comments
sorted by: hot top controversial new old
[–] caseyweederman@lemmy.ca 52 points 2 weeks ago (2 children)

You got me curious, so I looked it up.
This isn't a "let me google that for you", it's an "I'm joining you on this journey".

https://develop.kde.org/docs/apps/dolphin/service-menus/
(KDE)

Looks like you drop a .desktop file into ~/.local/share/kio/servicemenus.
Name the file extensions, write your Exec= line, fill in a couple other details like what icon to use and what it should be called in the right-click menu, save it, and you're done.
I imagine it's similar in xfce.

[–] caseyweederman@lemmy.ca 17 points 2 weeks ago

Looks like Thunar has a "Custom Actions" feature under the Edit menu where you can get the same result.

[–] john89@lemmy.ca 2 points 2 weeks ago (4 children)

Can I just say something? I personally view (almost) anything that involves editing configuration files by hand as an opportunity for the Linux community to implement a GUI.

[–] caseyweederman@lemmy.ca 2 points 2 weeks ago

You're absolutely right, I'm surprised that xfce (or Thunar anyway) has a GUI for it and KDE doesn't.
KDE might and I just didn't find it in the search results.

Pull request time!

[–] mactan@lemmy.ml 1 points 2 weeks ago* (last edited 2 weeks ago)

I still haven't had to edit any files for this task, I was able to install packages and check boxes in a gui to add menu items ( kde / dolphin )

[–] captain_aggravated@sh.itjust.works 0 points 2 weeks ago (1 children)

Thanks for volunteering yourself and your own time to this endeavor.

[–] john89@lemmy.ca 1 points 2 weeks ago (2 children)

So you admit the lack of GUIs on Linux is due to a lack of developers?

You don't think it's easier for users to edit configuration files by hand?

[–] Ephera@lemmy.ml 2 points 2 weeks ago

Well, more choice is a good thing. So long as the configuration file stays available as well (because it makes it way easier to script this configuration), then having a GUI available is cool, too.

Having said that, the particular feature that OP wants is for people who want to script things, meaning most of them will prefer the configuration file anyways. You'd need quite a lot of spare devs for one of them to get bored enough to want to develop a GUI, which will not see much usage.

Actually no I don't.

Linux doesn't lack GUIs; there's at least ten entire Desktop Environments in active development at any given time and several of them are quite feature complete such as Cinnamon and KDE. Then you've got GNOME which is polished if deliberately feature poor.

A few DEs do have GUI applets for editing the context menu but not all do. Windows doesn't have one built in. Quote the second page of that thread:

Id prefer NOT to use a third party app to make it work. I just wish Microsoft would just make is fully Customizable for us all.

I'm a subscriber to the old adage "GUIs make simple tasks easy, CLIs make complex tasks possible." This task is either within the city limits of shell scripting or close enough to read the "Speed limit 35 unless posted" sign, so it might as well be left as a "write a config file" type thing.

[–] verdigris@lemmy.ml 0 points 2 weeks ago (1 children)

Editing a config file takes a few seconds. Implementing a GUI takes hours of unpaid labor, and depending on the case the UX in the end might be almost identical.

[–] john89@lemmy.ca 1 points 2 weeks ago (1 children)

The UX at the end should never be identical.

It's why laypeople shy away from Linux. They prefer GUIs because GUIs are easier for users.

[–] verdigris@lemmy.ml 1 points 2 weeks ago (1 children)

Well, sometimes it's gonna be. What if there's a field that can take an arbitrary string? You would rather input that string into a styled form input with some buttons to click than use a text editor for a second?

[–] john89@lemmy.ca 1 points 2 weeks ago (1 children)

Absolutely!

How am I supposed to know where to find the file? Editing files by hand is also more error-prone compared to using a GUI. It's not for laypeople and they shouldn't have to adjust for it.

A big appeal of software development for me is making things easier for users even if it's harder for the developers to implement. That's good design, and great work.

[–] verdigris@lemmy.ml 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Okay if finding the file is the problem I assume you're just allergic to documentation, which, yeah, would make configuring things pretty annoying.

Hypothetically yes it would be great if all settings were easily discoverable and all users could easily make all their software work exactly how they want. In practice you're asking for a huge amount of development by unpaid volunteers whose time could be (and is) going to, for example, the actual features or configuration options that you're trying to set in the first place.

Most apps with GUIs do expose most settings that "laypeople" would use, anyway. OP is literally asking to be able to run custom scripts from context menus, I'd love to see your suggestion for implementing a clean and user-friendly GUI for that.

[–] john89@lemmy.ca 0 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Allergic to documentation? See, this is where the free software community fucks up. Stop putting the onus of usability on the users. It's the role of developers to make their software easy to use for people who aren't working on it. That's why macOS and Windows are still dominant to this day. The companies that develop them realized decades ago that laypeople don't want to and shouldn't have to read documentation or sift through configuration files if software can be designed so that it's easier to use.

Unfortunately, thanks to people like you, getting this solution across to the Linux community at large is like pulling teeth.

I'd be happier if we could just admit, "Yeah, GUIs are better but they're harder to implement so we don't do it." At least then we're being honest and not trying to blame users for the lack of developers.

As it stands right now, your rhetoric actively discourages people to take up GUI development because you keep trying to make it a user problem, not a developer one.

[–] verdigris@lemmy.ml 1 points 2 weeks ago* (last edited 2 weeks ago)

In FOSS, community & volunteer made software, yes, there is onus on you as the user to do a bare minimum of effort. You have to meet the developers and the software where it is.

I very literally said "GUIs are better but harder to implement." The second half of that sentence is not trivial.

If you want to customize and tweak things in the guts of a program (like OP does for this discussion), you can actually do it with FOSS applications. But expecting developers to expose every configurable option with a GUI would massively slow down the pace of development. Making them available in config files is a nice compromise between doing all that work and not exposing the option at all, in which case you'd need to actually patch the executable or otherwise modify the source code.

I'm not discouraging people from working on GUIs. I'm just pointing out the fact that if an app doesn't expose a setting you want to change, your options are a) complain that the dev hasn't implemented that, b) change it yourself which would be hugely easier if you looked the documentation, or c) find another app. Saying "the onus isn't on me" doesn't work when you don't pay for the software and the person who wrote it is a volunteer, it just makes you an entitled asshole.

[–] TootSweet@lemmy.world 11 points 2 weeks ago

Step 1) Install a file manager...

[–] eldavi@lemmy.ml 6 points 2 weeks ago (2 children)

some desktop environments and window managers have built in functionality to do this through something like config files or a gui config.

the intentionally "simplified" or "streamlined" alternatives (ie gnome) requires more involvement and runs at a gradient between simple kde like config file at one extreme end, to full on source modification at the other extreme end.

if something like this was a common thing for me; i would go with an environment that makes the bells and whistles available to you as the default option, like kde.

[–] deadcream@sopuli.xyz 4 points 2 weeks ago (1 children)

Even if a file manager doesn't have this feature, you can probably get around that by adding a new .desktop file in ~/.local/share/applications that accepts specific MIME type and runs a script on "opened" files.

[–] eldavi@lemmy.ml 2 points 2 weeks ago* (last edited 2 weeks ago)

that's the beautiful thing about linux; so many way to accomplish a goal and it you can do it at any experience level.

the best part is that all of it is free and your solution is easily shareable through things like social media and source code repositories where people with more experience can improve upon your idea further. if your idea is REALLY good, it will become mainstream.

I've often said the perfect GNOME utility applet is a blank window titled "Gnothing" with a button in the top bar that says "never mind", while the ideal KDE utility applet is the instrument panel of an Apollo CSM crashed at an oblique angle into the Chernobyl control room labeled "text viewer." And Cinnamon usually sits somewhere between those two extremes.

[–] wildbus8979@sh.itjust.works 6 points 2 weeks ago

Which file browser are you using?

[–] bortsampson@hexbear.net 6 points 2 weeks ago

Are you using GNOME or KDE? I know those can definitely utilize shell scripts from the right click menu. I'd recommend grabbing FFMPEG (probably already have it) and SOX. You are going to need to create a pretty basic shell script that extract the audio as a wav using FFMPEG, changing the speed with SOX (you can use FFMPEG but I find the audio warping dog shit), then FFMPEG to convert to mp3. For both GNOME and KDE the context menu shortcuts typically only pass the path to file you have selected as an argument. So you'll need to create a script for each speed. Honestly, it's not gonna be easy. You might find something in the Dolphin (kde filemanager) settings that will enable some basic context menu scripts for converting video to mp3. If this is too intimidating then I would check github for an FFMPEG wrapper. It's the a/v swiss army knife in linux.

[–] captain_aggravated@sh.itjust.works 5 points 2 weeks ago (1 children)

In the Cinnamon desktop, there's a directory in ~/.local/share/nemo/actions. Navigate to this directory in Nemo file manager and a message will appear across the top, it has a built-in tutorial as to how to do this. You create a short config file with a .nemo_action that defines what an action does, what context it appears in, what text it displays, what icon it displays etc. and the command to run when chosen.

It's been about a year since I've messed with this, but IIRC if it's set up to fire with one or more files selected, it will pass the file names to the command as arguments. You can configure it to run on exactly one, one or many, or specifically plural files. A thing I did a lot was allow it to take multiple files and then iterate across the variables in a for loop, so say I used pandoc to convert .docx files to .pdf, I could highlight 50 of them, click one option and it would churn through all of them.

I'm not going to build the script for you, but the first approach that occurs to me would be to write a shell script that calls ffmpeg to do the conversion, get that to where it works when you invoke it from the terminal, then write a .nemo_action file to fire it from the GUI.

As for the playback speeds...I'm not sure how to get that done. If you mean "take this .mp4 and make an .mp3 out of its audio that is 25% faster" I think what would happen there is you'd write a little GUI pop-up window, I would do it in Python with either a GTK or QT module, that would open up to ask parameters before passing that back to the main script to do the work.

[–] interdimensionalmeme@lemmy.ml 2 points 2 weeks ago (1 children)

Wow thanks I will try this cinnamon destop

Good luck! Hope it does what you want it to!