Category Archives: Tutorials

Tutorials for a variety of subject matter

Tutorial

Tutorial: Remove Firefox Title Bar On Linux KDE – Alternate Methods

the problem…

One of the issues i had when i scrapped Windows and installed Linux Mint was that i missed how easy it was to hide the Firefox window title bar in order to gain that extra bit of vertical real estate under Windows. With Mint and the KDE desktop environment i found several options to accomplish a similar result, but i liked none of them and so off i went seeking a better alternative.

Most of the the options i found either advised to install the Hide Caption Titlebar Plus extension for Firefox, which works on Linux, more or less, or to apply a custom window style using the Window Actions and Behavior settings in KDE (System Settings > Workspace > Window Management on Mint 18.x). The problem with the former is that it is hugely bloated with options i don’t use nor want and it didn’t produce a very nice looking result, plus i prefer to do things without installing more Firefox extensions if possible. The problem with the latter option is that, while it is indeed trivial to remove the Firefox window title bar using the Window Management tool provided by KDE, this left me with a borderless window that couldn’t be resized when it wasn’t maximized.

the solutions…

By accident i stumbled upon what i personally think is a better solution while playing with the KDE Window Decorations utility in System Settings > Appearance > Application Style > Window Decorations settings and no additional software or configuration tweaks were needed.

System Settings - Application Style
click to enlarge

On the Theme tab of the Window Decorations utility, you’ll see the previews of whatever window themes you have installed. In Mint 17.x/18.x with KDE, i think the defaults are Breeze and Plastik.

Window Decorations - Theme
click to enlarge

For this to work, you have to be using the Breeze theme or another one that supports windows-specific overrides (the Plastik theme does not, nor do any of the custom themes i tried). Using Breeze as the example, if you click on the little tool icon on the lower-left of the theme preview, you’ll get a menu which opens the settings for the theme.

Window Decorations - Theme Settings
click to enlarge

On the Windows-Specific Overrides tab you can add a couple of window specific styles for a given window, or even all windows if you want. The only two options are to change the border size and hide the title bar. These options are not nearly as comprehensive as those found in the System Settings > Workspace > Windows Management > Window Rules utility, but the difference between the two is that, as previously mentioned, you lose the window border and thus the ability to resize the window with the mouse when removing the title bar using the Window Rules utility, while you retain the window border when using the Windows Decorations utility.

So to accomplish what we want, simply click that little tool icon on the window theme preview and switch to the Windows-Specific Overrides tab. From here, click Add and a utility to identify the window for which you want to remove the title bar will be displayed.

Breeze System Settings - Add

In this window you have two options; you can either set the Matching window property to Window Title or Window Class Name. I recommend you select the Window Class Name option (if you don’t, you’ll eventually figure out why i recommend this option). In the Regular expression to match field, enter Navigator Firefox (in the image below i use Navigator Waterfox because i use Waterfox). In the next section you can enable or disable the window border size option if you want, but most importantly you’ll want to select the Hide window title bar option, then click “OK” and “Apply” and you’re done with this part.

 

KDE: Window-Specific Overrides

The caveat with this method verses using an extension, is that we lose our browser window exit, restore and minimize window controls and so you’ll have to get used to exiting Firefox using another method such as a keyboard shortcut or a menu item, but what i prefer is to simply middle-click the task bar icon to close windows. This is easily accomplished by right-clicking any task bar icon and selecting the Task Manager Settings menu item, then setting the On middle-click option in the General section to “Close Window or Group”. Note that i personally do not group windows.

Task Manager Settings - Plasma
click to enlarge

Returning to Firefox, you may still have a bit of a problem in that you will need a way to drag the window so we can restore (un-maximize) it, resize it and move it around since our title bar is now gone. My solution was to simply add a bit of fixed space to the end of the tab bar (i set tabs to be on top). This is really only needed when you have enough tabs open so as to fill the space on the tab bar. I suppose there are a couple of ways to accomplish this, including a userChrome.css hack, however the easiest way is to put the browser in customize mode and drag one or more fixed-width spaces to wherever you want on the tab bar.

Mozilla Firefox - Add Static Space
click to enlarge

So hopefully you now have an easy way to exit, move and resize Firefox, along with a bit more screen real estate, and it can all be done without having to edit a single configuration file.

Tutorial

An MP3 Collection Optimization Guide For Linux

FYI: This is a work in progress and not well tested at this point.

I’m fussy about my MP3 collection in that i like my music files to be properly formatted and free of errors. Having used Windows for most of my computing life, i had found many good editing and error correction tools over the years which served my needs quite well. Having recently moved to Linux Mint however, and not wanting to run Windows programs under Wine, i set out to duplicate my Windows tool chain on Linux and, as it turned out, i was more successful than i had anticipated so i decided to share my configuration.

This guide is primarily intended for formatting multiple audio files that have been downloaded from the web. In such a case, the files you download are often mis-tagged, damaged and/or not properly formatted and so we will use some pretty cool software tools to fix as many problems as we can. Note that all of the editing we will do with our MP3 files is non-destructive, meaning no re-encoding of the files is necessary and therefore there is no loss of sound quality.

Ideally, the end result of our work will be smaller, error-free MP3 music files that will have roughly the same volume according to the human ear.

This guide should work for all Debian-based distributions and possibly others.

Work Flow

Following are the basic steps i take to process my audio files:

  1. You may want to backup your audio files before you start
  2. File conversion if necessary (usually FLAC to MP3 in my case)
  3. Remove and rewrite all the meta tags
  4. Repair any errors in the files
  5. Trim all silence at the beginning and end of the tracks
  6. Normalize the volume so all tracks are about the same loudness
  7. Listen to all of the processed music to be sure it sounds good
  8. Organize the MP3’s into folders and/or playlists
  9. Copy the files to my devices

Tools Required

These are the tools i use to process audio files on Linux. You should check your package manager to see if they are all available and, if not, consider downloading them from their respective websites.

  • FFmpeg – a comprehensive file conversion and editing tool (it might be over-kill for just converting between FLAC and MP3, so feel free to use something else if you don’t require its many other capabilities)
  • puddletag – an audio tagging tool that is very similar to the much loved Mp3tag
  • MP3 Diags – a powerful Swiss Army Knife for repairing and tagging, if you like, MP3 audio files
  • Mp3splt – (yes, it’s spelled ‘splt’, not ‘split’) its primary use is to split MP3 files into multiple segments, however it works well for removing silence at the beginning and end of our MP3’s.
  • MP3Gain – for normalizing the volume across an entire album or multiple tracks (look in your package manager for the Linux version, or you can find it in the Ubuntu repository). This tool can be run via MP3 Diags.

Folder Structure

To keep things organized i would suggest creating the following folder structure. This is especially useful so that you don’t lose your place should you stop processing the files and wish to resume later.

  • -Incoming (drop files to be processed here if you don’t plan on working with them immediately)
  • -Replace (during processing, you may find that some files cannot be repaired and so you can drop them here until you find replacements)
  • 01 Convert
  • 02 Tagging
  • 03 Repair
    • Mp3splt_out
  • 04 Listen Test
  • 05 Organize
  • 06 Copy to Devices

Tool Settings

Following are only the most important settings that i use and recommend for the different programs:

puddletag (writing MP3 meta-tags)

  • Edit > Preferences > ID3 Options:
    • set: Create ID3v1 tag if it’s not present. Otherwise update it.
    • set: Write ID3v2.3

MP3 Diags  (fix errors, trim silence, normalize volume – Mp3splt and MP3Gain will be configured here):

  • Configuration > External tools:
    • add mp3splt command (be sure to set the input and output paths) (note that “konsole” is for KDE, other desktops may differ): konsole --hold -e /bin/sh -c "mp3splt -r -f -p th=-48 -o @f '/[source directory path]' -d '/[output directory path]'"
    • set: Confirm launch
  • Configuration > Others > Normalizer:
    • set: mp3gain -e -r -k -T -s a (note that the -T switch is optional – using it will write directly to the source file instead of creating a temporary file first)
    • set: Keep window open after completion

Convert non-MP3 to MP3 bash script – if necessary, create a bash script to convert your audio to MP3’s using FFmpeg. The following script will convert FLAC to MP3, encoding them at 320 BPS (Bits Per Second) CBR (Constant Bit Rate) and, if FFmpeg is successful, it will delete each FLAC file after it is converted. If you don’t want to encode your MP3’s at 320 BPS CBR, see this document for alternatives to -b:a 320k.

#!/bin/bash
 echo "FFmpeg convert .flac to .mp3" echo "============================"
 for a in *.flac ; do fmpeg -i "$a" -b:a 320k "${a[@]/%flac/mp3}" if [$? -eq 0]; then     rm "${a}" fi done
 echo "========" echo "Finished!"

Save the script as -flac2mp3.sh in your Convert directory and set the permissions so that it is executable. The dash in front of the file name will keep it on top of your other audio files so it’s easy to find.

Audio Processing

These steps should be followed in order as outlined above in the Work Flow section.

STEP 1: Backup your collection before processing.

STEP 2: Using your bash script, convert any FLAC audio files to MP3:

  1. Place all your FLAC files in the Convert directory
  2. Run the bash script flac2mp3.sh
  3. Delete the original FLAC files if desired and move the converted files to the Tagging directory

STEP 3: Rewrite all the MP3 meta-tags using puddletag:

Personally i prefer to remove all of the tags and rewrite them without any other data than the artist name and track name. You may want to do something different than what is outlined here, such as keep the existing tag data or download new data.

  1. Rename the files as necessary, removing any unwanted characters, etc.. It may be helpful to copy the tag names to the file names, but be careful when doing this.
  2. Select all of the tracks and delete all of the tags
  3. Select all of the tracks and copy the file names to the tag names
  4. Move the files to the Repair directory

STEP 4: Repair errors with MP3 Diags:

You should refer to the MP3 Diags manual to learn how to repair your MP3 files.

STEP 5: Trim silence from beginning and end of MP3 files using MP3 Diags:

  1. Right click any track and click the Mp3splt menu item to process all the tracks
  2. Delete the original files if desired and move the output files up one level back to the Repair directory

STEP 6: Normalize volume of MP3 files using MP3 Diags:

  1. Click the Normalize icon to process all the tracks
  2. Move the files to the Listen Test directory

STEP 7: Listen test:

  1. Listen to all of the tracks to be sure they sound good
  2. Move the files to the Organize directory

STEP 8: Organize your music:

  1. Organize the tracks into folders and/or play lists. You can use puddletag for this, your music player, etc., or you can simply use a text editor (an m3u file is nothing more than a text file with a list of file paths, though you should give it an m3u8 extension if the file is Unicode).
  2. Move the files to the Copy to Devices directory

STEP 9: Copy the files to your devices and test to make sure they play.