Archive for Linux

Changing the Android Default Alarm on Zenfone 2

I don’t like the default alarm sound on my phone much and apparently changing it to something a little bit gentler can only be done on a per-alarm basis. Luckily I found this:

Today I was looking for a way to change the sound that is applied by default to new alarms you create in the Alarms app. After quite a bit of effort I came upon the following procedure:

  1. Install ES File Explorer
  2. Open it and select / from the Favorites
  3. Browse to /system/media/audio/alarms
  4. Click on the file you want and in the "Open with" prompt select "ES Media Player"
  5. Click on the bell beside the file name, pick "Set alarm" and click OK

Should you choose to change again the default, you may notice that the defaults you pick will appear in the music library. Also, they will be listed twice in the tone selection list which appears when you manually change the tone of an individual alarm.

You can fix that with the following steps:

  1. Open Settings
  2. Go to Applications > Manage Applications > All
  3. Click on Media Storage and then Clear data
  4. Reboot your phone
  5. You will now have to set your new default sound

(I've noticed that sometimes, when you view a music album which doesn't have a cover art image and add an album.jpg file to it later, Music Player will not use that file for the cover art. The above steps, as a side effect, will make Music Player look for images for all albums, thus having the cover art of all your albums updated.)

Hope this helps 🙂

Comments

You Can Just Concatenate MPEG-2

To deal with the inferior FAT file system, it would seem that consumer-level Sony video cameras write video files of a maximum of about 2.1 GB. A sensible approach, but annoying to work with. Luckily they can be concatenated without any concerns or side effects for easier viewing and editing.

cat 00006.MTS 00007.MTS 00008.MTS > output.mts

For other video formats, see the ffmpeg FAQ.

CommentsTags:

Launcher with parameters in Xfce

Back in November I decided to try Aard 2 on my laptop. I followed the instructions and it worked. Then I created a launcher with the following command and suddenly it did not.

java -Dslobber.browse=true -jar ~/programs/aard2/aard2-web-0.7.jar ~/programs/aard2/slobs/*.slob

A different strategy, passing a command to Bash, did the trick.

bash -c "java -Dslobber.browse=true -jar ~/programs/aard2/aard2-web-0.7.jar ~/programs/aard2/slobs/*.slob"

Enjoy your fully functional launcher! 😉

CommentsTags: ,

Qalculate!, My New Favorite Calculator

Over the past few years I acquired a bad habit of using search engines for basic calculations and conversions. I’m not talking about the stuff you should just do in your head — not quite that bad, but about the fact that several Linux distros, including my favorite of Debian Xfce, don’t seem to ship with a calculator by default. So I finally got around to testing some programs and Qalculate! does all I want. You can install it on Debian using sudo apt install qalculate-gtk. There’s a list of features on the website. Enjoy a few screenshots.

qalculate-conversion-celsius-fs8
Celsius to Fahrenheit.
qalculate-conversion-km-fs8
Kilometer to mile.
qalculate-conversion-money-fs8
Euro to Dollar.

I hope you’ll like it too!

CommentsTags: , ,

Image Optimization Guide

On the forum I administer, I am forced to run a tight attachment policy. Disk space doesn’t grow on trees. Occasionally this leads to questions about the small attachment size limit of 50 KiB. This guide is intended to clarify that this is not nearly as tiny as you might think. Note that although I’ll mention commands without much explanation for the sake of brevity, you’re always recommended to further explore the possibilities offered by those commands with the --help flag as well as by running man the-command-here.

First you need to ask yourself what kind of file type is appropriate, if you have the choice. On screenshots, the main purpose of attachments on my forum, you’ll often encounter large areas of uniform background colors. PNG is therefore almost invariably the right choice. Crop out everything but what’s relevant. JPEG is appropriate for more dynamic pictures such as photographs. If you want to do a lot with photographs, you might want to consider an external hosting service. My wife likes SmugMug. Still, for thumbnails you might be able to do a fair bit more within a few hundred KiB than you might think. Finally, the vector graphics in SVG result in pictures that always look sharp. You’ll typically have drawn these in a program like Inkscape or Adobe Illustrator.

Table of Contents

  1. 1. Optimizing JPEG
  2. 2. Optimizing PNG
  3. 3. Optimizing SVG
  4. Addendum A: Scanned Documents
  5. Addendum B: Video

1. Optimizing JPEG

Often you’ll want to crop your file. Do not edit your JPEG followed by resaving it because this will result in reduced quality! You can crop losslessly with cropgui. On Windows you can use IrfanView.

If you don’t want to crop, and also potentially for some post-cropgui optimization, use jpegtran -copy none -progressive -optimize file.jpg > file-opt.jpg. Note that this will get rid of all metadata, which may be undesirable. If so, use jpegtran -copy all -progressive -optimize file.jpg > file-opt.jpg.

Of course if you want to scale down your JPEG there’s no point in mucking about with lossless cropping first. After scaling down, check how long your quality can go (also see a little helper script I wrote). In any case, you should avoid introducing any unnecessary compression steps with associated quality loss. Here are some results:

  • The original 11.jpg at 2.19 MB.
  • Losslessly cropped 11-crop.jpg at 1.11 MB.
  • Optimized with -copy all -progressive -optimize 11-crop-opt.jpg at 1.04 MB. -copy none would’ve saved an extra whopping 40-some KiB, which on this kind of filesize has little benefit, and besides, I quite like the metadata. For thumbnail-sized files the balance is likely to be different. For example, the 52.2 KiB SmugMug auto-generated thumbnail below can be insignificantly reduced to 51.1 KiB with --copy all, but to 48.2 KiB with --copy none. I think an 8% reduction is not too shabby, plus it brings the file size down to under the arbitrary 50 KiB limit on my forum.

2. Optimizing PNG

As I wrote in the introduction, for screenshots PNG is typically the right choice. If you want to use lossless PNG, use optipng -o7. In my experience it’s ever so slightly smaller than other solutions like pngcrush. But as long as you use a PNG optimizer it shouldn’t much matter which one you fancy. Also see this comparison.

If you don’t care about potentially losing some color accuracy, use pngquant instead. To top it off, if you really want to squeeze out your PNG, you can pass quality settings with --quality min-max, meaning you can pass --quality 30-50 or just --quality 10. Here are some quick results for the screenshot in the SVG section below, but be sure to check out the pngquant website for some impressive examples.


$ du -h --apparent-size inkscape-plain-svg.png
27K	inkscape-plain-svg.png

$ du -h --apparent-size inkscape-plain-svg-fs8\ default.png 
7.6K	inkscape-plain-svg-fs8 default.png

$ du -h --apparent-size inkscape-plain-svg-fs8\ quality\ 10.png 
4.3K	inkscape-plain-svg-fs8 quality 10.png

In this case there is no visual distinction between the original PNG and the default pngquant settings. The quality 10 result is almost imperceptibly worse unless you look closely, so I didn’t bother to include a sample.

3. Optimizing SVG

For using SVG on the web, I imagine I don’t have to tell you that in Inkscape, you should save your file as Plain SVG.

Save as Plain SVG in Inkscape.

What you may not know is that just like there are lossy PNGs, you can also create what amounts to lossy SVGs. There are some command-line tools to optimize SVGs, including (partially thanks to this SO answer):

  • Scour is probably the best command line tool for some quick optimization. You can just use the defaults like scour < in.svg > out.svg or scour -i in.svg -o out.svg. But I recommend you go further.
  • SVGO (SVG Optimizer)
  • SVG-optimiser (by Peter Collingridge)
  • SVG-editor (by Peter Collingridge)

My personal preference for squeezing out every last byte goes toward the web-based version of the SVG-editor by Peter Collingridge. By running it in a browser with inferior SVG support such as Firefox, you’ll be sure that your optimized SVG still works properly afterward. The command line tools can only safely be used for basic optimizations, whereas the effects of going lossy (such as lowering precision) can only be fully appreciated graphically.

Addendum A: Scanned Documents

Scanned documents are a different item altogether. The best format for private use is DjVu, but for public sharing PDF is probably preferable. To achieve the best results, you should scan your documents in TIFF or PNG, followed by processing with unpaper or ScanTailor. If you’ve already got a PDF you’d like to improve, you can use pdfsandwich or my own readablepdf.

Addendum B: Video

I’m not aware of any lossless optimization for video compression such as offered by jpegtran, but you can often losslessly cut video. In the general purpose editor Avidemux, simply make sure both video and audio are set to copy. There is also a dedicated cross-platform app for lossless trimming of videos called, unsurprisingly, LosslessCut. If you do want to introduce loss for a smaller file size you can use the very same Avidemux with a different setting, ffmpeg, mpv, VLC, and so forth. You can get reasonable quality that’ll play many places with something like:

ffmpeg -i input-file.ext -c:v libx264 -crf 19 -preset slow -c:a libfaac -b:a 192k -ac 2 output-file.mp4

For the open WebM format, you can use something along these lines:

ffmpeg -i input.mp4 -c:v libvpx -b:v 1M -c:a libvorbis output.webm

More examples on the ffmpeg wiki. Note that in many cases you should just copy the audio using -acodec copy, but of course that’s not always an option. Extra compression artifacts in audio detract significantly more from the experience than low-quality video.

CommentsTags:

libGL error in Steam and Broken Age in Debian Stretch

After some update or other, Broken Age refused to start.

$ ./start.sh 
Running Broken Age
libGL error: unable to load driver: radeonsi_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: radeonsi
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  91
  Current serial number in output stream:  92

Oh well, let’s give it a little hand, shall we?

LD_PRELOAD='/usr/lib/i386-linux-gnu/libstdc++.so.6 /lib/i386-linux-gnu/libgpg-error.so.0' ./start.sh

This loads the included libraries before any others, in order to override the incompatible libraries shipped with the program in question. The same trick also works for Steam. If gaming is your goal, you should probably stick to whatever version of Ubuntu is supported best. I’m just pleased that I can play the occasional game like Oxenfree (no preloading required, mind you) or Broken Age on my workhorse without having to install any stability-reducing binary blobs.

Comments (1)Tags: ,

Fix No gksu(do) Permissions Prompt on Gparted, Synaptic, Mounting Drives, Etc. in Debian

I run Debian Stretch (testing) as my daily driver, and at some point I stopped being able to start programs like start Synaptic, Gparted, Synaptic etc. without manually typing gksu(do). The solution is as simple as it is seemingly unnecessary and stupid:

sudo apt install policykit-1-gnome

The problem is apparent upon reading the description:

This implementation was originally designed for GNOME 2, but most
GNOME-based desktop environments, including GNOME 3, GNOME Flashback,
MATE and Cinnamon, have their own built-in PolicyKit agents and no
longer use this one. The remaining users of this implementation
are XFCE and Unity.

Reported as Debian bug #843224. My first?


D’oh, I wrote this on November 5, 2016. I’ll still publish it anyway in case it’ll still help someone searching for a solution.

CommentsTags: ,

Workarounds for Turning Off Your DisplayPort Monitor

Sometimes you jot down a few quick notes for yourself without bothering to turn them into a blogpost that might be useful to others. This is one of those notes. First, I’ll introduce my computer monitor workflow as it’s been since time immemorial, also known as ’95 or ’96. Just like how I turn off lights I don’t use, I’ve always turned off my monitor when I wanted it. This has never been a problem, until in early 2015 I had to use DisplayPort for the first time. If you want an UltraHD monitor, which you do if you care even the tiniest bit about sharpness and clarity, you have to use DisplayPort.

But DisplayPort isn’t nice. Turning off your monitor is treated the same as disconnecting it. In Windows this means everything resets itself to some absurdly low resolution, whereas in Linux the consequences can be even worse (like having to SSH in from another computer to run an xrandr command to reactivate the monitor). This means you either face a colossal waste of energy or continuous annoyance at the fact that your monitor has turned itself off yet again. In my view monitor timeouts should be at least twenty minutes, just as a failsafe in the extremely unlikely event that you forgot to turn it off. Luckily I found two reasonable workarounds within the first week or two of having acquired my UHD monitor.

The first?

xset dpms force off

This has the same effect as your monitor timeout, only at your volition. I tend to find the blinking light on the monitor somewhat annoying, but this nevertheless remains your best bet to quickly turn the screen off as part of your regular workflow.

The second method consists of actually turning the monitor off. Besides getting rid of the blinking light I figure it saves just a tiny bit more electricity to boot. Which is useful if you want to keep your computer active, but not your monitor. For this method you have to switch to TTY (Ctrl + Alt + F1-6) before turning your monitor off. Then when you turn your monitor back on, X won’t know it’s been missing. Switch back with Ctrl + Alt + F7.

I’m still hopeful that there might simply be an xorg.conf setting I’ve overlooked, but in any case these workarounds serve their purpose. Note that xset dpms force off is also tremendously useful on laptops that don’t have a function key for turning off the screen. Standby often just isn’t what you want.

CommentsTags: ,

Scanning with an HP MFP (multi-function peripheral) on Debian

You need to install hplip. It looks like something’s still off about the colors compared to Ubuntu and Windows, and I can’t figure out what the difference is. Alas. :/ Also, don’t buy HP.

CommentsTags: , , ,

Less is More

A minimal Debian install comes without the ability to view man pages. Fair enough, it’s minimal after all. But they can be quite useful. A sudo apt install man later results in man pages being shown. That’s all, folks? Unnfortunately not, because the man pages are shown using the more command, which doesn’t allow for scrolling up and down with the arrow keys or j and k, Pg Up and Pg Dn, and all the other usual niceties. To fix you need to sudo apt install less, a “pager program similar to more.” And better, at least on any machine with sufficient RAM. Meaning anything anyone is likely to use in 2016, or probably also in 1990 for that matter.

CommentsTags: ,

Older Entries »