Tuesday, March 24, 2020

How do I Give Sudo Privilege to a GUI application

This will be a quicky tip.

We all know of the sudo giving temporary root privilege to command-line functions, but what about GUI programs? They need the GUI authentication, or there will not be a chance to enter it.

Well, there is a new command in town to accomplish this task, you can enter pkexec and it will give you a graphic authentication for root useage.

Example: to open Nemo files with root privileges, go to a terminal and type in:

pkexec nemo

Once you hit enter, it will allow you to enter your password and run the program with root privilege. That's it!

How to create desktop program launchers in Linux

I've seen some people, like myself, that tend to create shortcut keys for their favorite programs. For others, with only a few favorites, they'll create panel shortcuts. For others, however, they literally litter their desktop with a slew of icons, much like they might for their smart phone.

This tendency probably occurs because when Windows first came out, nearly every program you installed in it would pop in what was called a desktop "shortcut." They called it that because it was a shortcut in contrast to going through the menu to start it. In LInux, they are called "launchers," because, well, they launch programs.

Programs in LInux systems, however, rarely do that, which is why you'll usually see Linux desktops with hardly any icons. Usually just the Computer file system, the home directory of the user, and often any mounted drives like a CD or USB drive.

As with most things in Linux, there are several ways to skin this cat, and which option will work for you depends upon which desktop GUI (Graphical User Interface) you are using.

For example, I use a Cinnamon desktop GUI. The easiest way to create desktop launchers of your most used programs is to use the menu to browse until you've found the program you want to use. Alternately, you can use the search function at the top to easily find any program. Then right-click on the program and select "Add to Desktop" from the pop-up menu. If you try that in whatever GUI you are working in and that option isn't there, never fear. There are other options.

Also, the following method can be used for command-line programs for which there are not graphical interfaces at your ready, like the text-based editor: nano.

In Cinnamon, and other GUIs, you can often right-click on an open spot on your desktop.  There you will see in the pop-up menu, one choice that says, "Create New Launcher Here..." GUIs other than Cinnamon will likely have similar wording. If not, there is still yet another option which I will go through in a minute.

What pops up in Cinnamon looks like this:


Different GUIs will likely have similar fields. First, you will likely want to change the icon to one more resembling the program you are about to enter. To do that, click on the icon above, which resembles a rocket. You can browse or search your options there to select one.

Then you'll want to give your program a name, like "Silly Windows clone of Explorer" Whatever you type there will be displayed below the icon on your desktop.

Next, you'll fill in the command-line part of the program. This is the command you would type into the terminal on a command-line, with an appropriate place holder for any file that would tend to go with it.  Since the default is to include any file after it, there is no need for a place holder for LibreOffice Writer.

For instance, if you wanted to create one for LibreOffice Writer, the command would be lowriter  or libreoffice --writer

Don't know the command-line version of a program? Here's how you find it. Open the terminal (Ctl-Alt-t) and enter the following: man (progam name)  It will then display a "manual page" for the program. Look under the "Synopsis" section, and it will tell you the command to run it, and further on it should tell you if it needs a parameter to use any files passed to it. Another option is to enter in the terminal: libreoffice -h or --help. That will give you a shorter listing of the command-line entry, but man is more complete and you have a chance to see the beginning without having to scroll back up if the help info is larger than a page.

So, if you entered "man libreoffice", you would get an extended help file listing out the things to know. You can also enter "info (your program) to get a cleaner Synopsis information.

Going back to entering the info in our launcher window, the next field is the Comment section. This is a "what this program does" spot and will show up whenever someone hovers over the icon. Something like "A cool word processor"

The next entry is whether or not to click the box next to "Launch in Terminal." You'll want to click it if it is going to run a command-line only program, like nano. Otherwise, you'll want to leave it unchecked.

For instance, let's say you wanted to have a desktop entry that would check if any of your programs from your repositories needed upgrading. You would create a launcher with the name of "Update check," then the command: sudo apt list --upgradable, a comment that says "Check to see if any upgrades need to be done," then click the box that says to Launch in Terminal.  Once you hit OK, it will put an icon on the desktop that will launch the apt program, and after verifying your credentials, it will give you a list of all upgradable programs in the terminal window.

Once you hit OK, it will then give you the option to put it in the menu as well. Just say nope or you can click it and follow the instructions for it to preform that function.

So, you don't have either function, how do you accomplish that ability?

For this option, you'll be creating and editing a desktop file.

Where are these files? For systemwide icons for everyone who might log in, put the desktop files in /usr/share/applications (you'll need root usr privilege). For each logged in person, you can put the files into their home directory: /home/$USER/.local/share/applications or /home/$USER/Desktop on Cinnamon.

The simplest way to accomplish this is to copy a file and paste it right back, then edit the new file to reflect the new information, paying attention especially to the name, exec, and comment sections. You can change the terminal to true if you need it. Don't forget to rename the file itself to (whatever you want to call it).desktop   

You can create the file from scratch. Before you do that, it would be a good idea to check this more detailed article on what to enter.

There you go. Another reason why I like Linux Mint Cinnamon, it makes it real easy to do what would be a more manual and not user friendly functions.

Monday, March 23, 2020

Intro and First Tip: Extracting Audio from a Video File

Howdy, Linux partners!

I'm starting this Linux blog because I keep thinking, once I've figured out how to do something in Linux, that I should share it with the world, so those who are searching for answers will find them.


To that end, i'll state that there are a lot more people with a higher knowledge of Linux than I. They often know all the obscure commands from memory, whereas I often have to look them up. While I don't consider myself an Linux guru, I have used it as my main OS for several years now. I started out using Lubuntu using the LXDE interface (GUI), then moved to Xubuntu using a xfce GUI (Graphical User Interface). I really liked the xfce GUI, save for a couple of small issues.

I kept hearing about Linux Mint, and what a good setup it is. So I decided to give it a spin. I also heard a lot of good things about the Cinnamon GUI, which is one of the GUI's you can get installed, the other two being the other two being MATE and Gnome. Likely you could install other GUI's on top of the Mint system.  I thought about using xfce but I was hoping I could solve the problems that I mentioned. So I tried Cinnamon and I loved it.

My issues? One was the xfce power manager didn't have an option for "do nothing when the lid is closed" and the date/time function required one to look up date coding in order to adjust the display to your preferences.

I was presently sold on Cinnamon when I clicked on the system date. It pops up a calendar, like they all do. However, it has a link at the bottom of the calendar that says, "Date and Time Settings". I clicked on it, expecting the code entry fields. What greeted me, however, was a GUI for setting the date and time so I didn't have to go search for the codes on the web. (LIke a common set of codes looks like this: %h%h:%m%m. That's when you know you have a good system, when the programmers pay attention to small details like that.

But, that is not my first tip on this blog. My first tip will be concerning how to extract music/soundtrack from a video. It is actually easier than you would think.

I use OpenShot to edit my videos. It isn't a full-featured editor, but it gets the job done. One of its drawbacks is being able to separate the audio from the video. Ideally I'd like to edit them in the program. But, without that option, I would need to first extract the music from a video file, edit it with a program, then import it back into your project.

To extract the audio from the file for editing, first you should have a program called Audacity. That one would normally be in the repositories. If not, you can download it from their website.  Once installed, all you do is open the video file with Audacity and it will (at least I've tried it with mp4 files, your mileage may vary) show only the audio in the file, which you can then edit and save as a mp3 file, ready to re-import into OpenShot.

Yes, it really is that easy.