Using a fast and reliable, still not obsolete, desktop environment with Fluxbox

Something like 6 years ago, I already described desktop environment I used over years. I was, since then, decently satisfied by KDE/Plasma/however you name it. Mostly because kmail works properly with IMAPS and handle CardDav-cloud server out of the box, because Dolphin is the best file browser (immediate filter and group files and directories by day are the feature I enjoy most and none other file browser I know got right) and the rest (akregator, korganizer with CalDav) ok.

But systemd arrived. I was curious at first and encouraged, on this very blog, people to give it a try. But soon  enough I found out I was faring better without, reaching the conclusion that “Point is with systemd, I’m able to do less and it takes me more time”. I moved away from systemd and, then, as consequence, of Debian. And I found out that KDE was increasingly getting dependant on systemd, with bug reports about regression in their software being closed advising to use systemd.  It led me, in 2015, to ask on /. Will You Be Able To Run a Modern Desktop Environment In 2016 Without Systemd? as follows:

Early this year, David Edmundson from KDE, concluded that “In many cases [systemd] allows us to throw away large amounts of code whilst at the same time providing a better user experience. Adding it [systemd] as an optional extra defeats the main benefit“. A perfectly sensible explanation. But, then, one might wonder to which point KDE would remain usable without systemd?

Recently, on one Devuan box, I noticed that KDE power management (Powerdevil) no longer supported suspend and hibernate. Since pm-utils was still there, for a while, I resorted to call pm-suspend directly, hoping it would get fixed at some point. But it did not. So I wrote a report myself. I was not expecting much. But neither was I expecting it to be immediately marked as RESOLVED and DOWNSTREAM, with a comment accusing the “Debian fork” I’m using to “ripe out” systemd without “coming with any of the supported solutions Plasma provides“. I searched beforehand about the issue so I knew that the problem also occurred on some other Debian-based systems and that the bug seemed entirely tied to upower, an upstream software used by Powerdevil. So if anything, at least this bug should have been marked as UPSTREAM.

While no one dares (yet) to claim to write software only for systemd based operating system, it is obvious that it is now getting quite hard to get support otherwise. At the same time, bricks that worked for years without now just get ruined, since, as pointed out by Edmunson, adding systemd as “optional extra defeats its main benefit”. So, is it likely that we’ll still have in 2016 a modern desktop environment, without recent regressions, running without systemd?

I replied once to comments in this article, for instance (not that l like to quote myself, but I’d rather avoid repeating myself):

Yeah and no. As pointed out in the article, the culprit is upower. But upower is mandatory for KDE power management. So it does not really matter whether it is Powerdevil that requires systemd or upower. ConsoleKit2 recently gained support? Was ConsoleKit2 actually been packaged? Does upower supporting ConsoleKit2 been packaged? If not, user experience wise, that is not palatable. And moreover, what to expect from upower? Did they not purposefully removed pm-utils support, that worked until then, in favor of systemd? Why removing support for a working solution (pm-utils) and, later, much later, adding support for some ConsoleKit2? What is the exact plan of ConsoleKit2? Providing some systemd-like interface without being systemd? Is that what ConsoleKit2 offers that pm-utils could not? If so, wow long will it work, to attempt to write a parallel to systemd, in order to make sure that all the software that in the past worked without systemd can now work with the systemd alternative? Just as a reminder, ConsoleKit2 exists “because there isnâ(TM)t currently a standard for system actions like suspend/hibernate anymore. We use these features in Xfce and it would be nice to keep the session manager and power manager in sync (i.e. you inhibit something and the session manager doesnâ(TM)t see it). Obviously thereâ(TM)s systembsd in the works, so this is a stop gap until that matures (however long that may be). But Iâ(TM)ll happily continue to maintain and support ConsoleKit2 as long as someone finds it useful”. https://erickoegel.wordpress.c… [wordpress.com] The acknowledged benefit of systemd, as pointed out by Edmunson (link in the article) was to drop code. If ConsoleKit2 and al needs to write code to compensate from all the dropped code, following systemd, that unlikely sustainable. The stop gap project won’t do. And it is really the funny thing now with systemd: if you dont want it, you need to write everything that it does because all the anterior/historical parts, good or bad, are getting deprecated and removed. So in order not to use systemd, you need to clone it. Bonkers. Hence the question: will KDE be still usable in 2016 without systemd.

Since then, I noticed a few other small issues which I did not bother to report: the answer would have been the same. So it is near one year later after my question asked on ./ and the answer is grim. More KDE parts got broken for me (sound, etc).

So I resorted to old answers, tested previously using desktop. I found Fluxbox to be the easiest to set up in a way that suits my needs.

Along with fluxbox, you need tint2 and xcompmgr, all properly packaged in Devuan. Then it is just a matter of editing files in ~/.fluxbox (after starting it once):

~/.fluxbox/startup :

#!/bin/sh
#
# fluxbox startup-script:
#
# Lines starting with a '#' are ignored.

# background image
fbsetbg ~/.fluxbox/backgrounds/selje.png &
# modern panel
tint2 &
# desktop transparency
xcompmgr -c &
# sysinfo panel
conky &
# required for dolphin to show up cleanly
export XDG_CURRENT_DESKTOP=kde
# desktop pager
fbpager -w &
# XMPP client
pidgin &
# cloud sync client
owncloud &
# gpg/ssh agents
eval "$(gpg-agent --daemon)" &
eval "$(ssh-agent)" &
# screen temperature
redshift &

[...]

~/.fluxbox/keys :

Control Mod1 A :Exec urxvtc
Control Mod1 I :Exec firefox
Control Mod1 M :Exec kmail
Control Mod1 E :Exec emacs
Control Mod1 D :Exec XDG_CURRENT_DESKTOP=kde dolphin

[...]

# if these don't work, use xev to find out your real keycodes
XF86AudioRaiseVolume :Exec amixer sset Master,0 2%+
XF86AudioLowerVolume :Exec amixer sset Master,0 2%-
XF86AudioMute :Exec amixer sset Master,0 toggle
#XF86AudioPlay
XF86AudioPrev :Exec /usr/local/bin/switch-sound
XF86AudioNext :Exec /usr/local/bin/switch-redshift

[...]

# sleep fluxbox CTRL-ALT pause
Control Mod1 127 :Exec sudo hibernate-ram

[...]

~/.fluxbox/init (just to set of fluxbox toolbar since we use tint2 instead) :

session.screen0.toolbar.visible: false

~/.conkyrc (need to be edited, for instance eth device names, etc):

conky.config = {
 alignment = 'bottom_left',
 background = yes,
 border_width = 1,
 cpu_avg_samples = 2,
 default_color = 'white',
 default_outline_color = 'white',
 default_shade_color = 'white',
 draw_borders = false,
 draw_graph_borders = true,
 draw_outline = false,
 draw_shades = false,
 double_buffer = yes,
 use_xft = true,
 font = 'Oxygen Mono:size=10',
 gap_x = 25,
 gap_y = 25,
 minimum_height = 5,
 minimum_width = 5,
 net_avg_samples = 2,
 no_buffers = true,
 out_to_console = false,
 out_to_stderr = false,
 extra_newline = false,
 own_window = true,
 own_window_class = 'Conky',
 own_window_type = 'override',
 own_window_colour = '#3d3d3d',
 stippled_borders = 0,
 update_interval = 2.5,
 uppercase = false,
 use_spacer = 'none',
 show_graph_scale = false,
 show_graph_range = false
}

conky.text = [[
# in red if sound off
${if_match "[on]" == "${exec amixer get Master | egrep -o '\[on\]' | tail -1}"}$
{color #4d4d4d}${else}${color Dark Salmon}${endif}
# assume left/right channels have same volume level
${execbar amixer get Master | egrep -o '[0-9]+%'| sed s/\%// | tail -1}
############
#${color #4d4d4d}$hr
${color grey}↑${color #4d4d4d}${upspeedgraph eth2 25,140} ${color grey}↓${color 
#4d4d4d}${downspeedgraph eth2 25,140}
###########
#${color #4d4d4d}$hr
#${color grey}CPU: ${color white}${i2c isa-0228 temp 2}°C$color - MB: ${color wh
ite}${i2c 9191-0290 temp 1}°C
###########
#${color #4d4d4d}$hr
${color grey}Name PID CPU% MEM%
${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
${color lightgrey} ${top name 5} ${top pid 5} ${top cpu 5} ${top mem 5}
${color lightgrey} ${top name 6} ${top pid 6} ${top cpu 6} ${top mem 6}
${color lightgrey} ${top name 7} ${top pid 7} ${top cpu 7} ${top mem 7}
]]

shot.png

With this setup, the only thing I actually miss is a icon-tasklist.

Avoiding GPG issues while submitting to popularity-contest on Devuan

For some reason, on Devuan, popularity-contest submits fails with:

gpg: 4383FF7B81EEE66F: skipped: public key not found
gpg: /var/log/popularity-contest.new: encryption failed: public key not found

The Debian Popularity Contest being described as an attempt to map the usage of Debian packages, I think useful that it also get stats from disgrunted Debian users forced to use a fork of the same general scope.

I do not think it data transmitted in this context is really sensitive. So the simplest hack is just to set off encryption by adding to /etc/popularity-contest.conf:

ENCRYPT="no"

Dealing with WRITE FPDMA QUEUED hard disk trouble

Recently, on one of my servers, I had the main hard disk being set to failsafe read-only with the following ATA errors logged in /var/log/kern.log:

ata1.00: failed command: WRITE FPDMA QUEUED
ata1.00: cmd 61/00:90:40:7e:85/04:00:ea:00:00/40 tag 18 ncq 524288 out
res 40/00:0c:40:b6:85/00:00: ea:00:00/40 Emask 0x10 (ATA bus error)
ata1.00: status: { DRDY }
ata1.00: failed command: WRITE FPDMA QUEUED
ata1.00: cmd 61/00:98:40:82:85/04:00:ea:00:00/40 tag 19 ncq 524288 out
res 40/00:0c:40:b6:85/00:00:ea:00:00/40 Emask 0x10 (ATA bus error)
ata1.00: status: { DRDY }
ata1.00: failed command: WRITE FPDMA QUEUED

It looks like a physical issue with the drive. Though there was no specific error reported by  smartctl -a /dev/sdX, and the disk was quite new (just one year old), a Western Digital Red (SATA 3 model WDC WD40EFRX-68WT0N0). The mainboard being only SATA 2, the drive is not at all pushed to its limits.

The SATA cables were the same age and SATA 3 and not in bad apparent condition except it looks like they did not stayed perfectly plugged in over time.

I switched the apparently faulty disk to the SATA connector used by the secondary hard disk and made sure they are both  properly plugged: so far, it fixed it. It really looks like a SATA cable issue.

 

Creating primitive subtitle (SubRip/.srt) file from scratch

I had a video I wanted to add a few subtitles lines here and there, without much effort. I ran:

$ apt-cache search subtitle editor
aegisub - Advanced subtitle editor
aegisub-l10n - Aegisub language packages
gaupol - subtitle editor for text-based subtitle files
libsubtitleeditor-dev - subtitleeditor lib - development files
libsubtitleeditor0 - subtitleeditor lib - runtime files
subtitleeditor - Graphical subtitle editor with sound waves representation
python-aeidon - reading, writing and manipulating text-based subtitle files
gnome-subtitles - Subtitle editor for the GNOME Desktop environment

and installed a few of them.

I was quite a disappointing experience. These softwares are more or less working but none was easy and fast enough to use for me not to prefer just using mpv and emacs, viewing with mpv and typing relevant lines in a text file with  timestamps.

Some of these softwares looked almost ok but adding new lines that was generally inconvenient (not able to insert at the exact place the playthrough is paused, or supposed to be able to but simple not working).

So, yeah, I got the simple way and built a file like :

1:01:01 adjkajdalm kadmùlajpod jaaaaaaaa aaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa
11:01:01 adjkajdalm kadmùlajp odjaaaaaaaaa aaaaaaaaaaaaaaaaaa
111:01:01 adjkajda

And wrote a fast primitive script as follows:

#!/usr/bin/perl
use strict;
my $file = "THIS";
open(IN, "< $file.txt"); # input
open(OUT, "> $file.srt");
my $count = 0;
while (<IN>) {
 next if /^\s$/; #skip empty
 $count++;
 print OUT "$count\n";
 if (/^(\d{1,3})\:(\d{2}):(\d{2})\s/) { # extract time HH:MM:SS
 my ($h, $m, $s) = ($1, $2, $3);
 s/^$h:$m:$s\s//g; # remove the time from the line
 my $duration = 3; # 3 sec average duration 
 $duration = 5 if length($_) > 34; # 5 for almost two lines
 $duration = 2 if length($_) < 15; # 2 when very short
 
 my ($hplus, $mplus) = ($h, $m);
 my $splus = ($s + $duration);
 if ($splus > 60) { $mplus = ($m + 1); $splus = ($splus - 60); }
 if ($mplus > 60) { $hplus = ($h + 1); $mplus = ($mplus - 60); }
 
 print OUT sprintf("%02d:%02d:%02d,000 --> %02d:%02d:%02d,000",
 $h, $m, $s,
 $hplus, $mplus, $splus)."\n";
 } else {
 print "$count TIME ?\n"; 
 }
 print OUT $_;
 print OUT "\n";
}
close(IN);
close(OUT);
#EOF

It requires $file to be set accordingly to the name given to the input text file, obviously.

When satisfied with the written .srt, it’s convenient to embed it in the end file:

ffmpeg -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4

 

Creating an mp4 with black screen and silent audio (with ffmpeg)

Assuming you have a  black PNG image named blck.png, you can make it a mp4 video:

ffmpeg -loop 1 -i blck.png -t 900 -r 1 -c:v libx264 blck.mp4

And if you want to concatenate it with other mp4 (see previous post), it also needs to include a sound track. So, assuming your main files are in 48000hz (otherwise adjust), you can add it with the command:

ffmpeg -f lavfi -i anullsrc=r=48000 -i blck.mp4 -to 00:15:00 -c:v copy -c:a aac -strict experimental blck-snd.mp4

(note : -to needs to be set to the expected time, option -shortest fails)

 

 

Concatenating mp4 videos (with ffmpeg)

mp4 cannot be concatenated directly. But fmpeg (and so avconv I guess) can by the way of intermediary mpeg transport streams.

Here’s a dirty bash script that does that assuming you want to concat files named like MYFILE-1.mp4 MYFILE-2.mp4. Then you would just execute the script with MYFILE- as argument.

#!/bin/bash
echo $1
[ ! -e "$1"1.*4 ] && echo "nothing for $1""1.mp4" && exit

list=""
for i in `seq 1 20`; do
[ ! -e "$1"$i.*4 ] && continue
echo "$1$i.mp4 exists, creating $1$i.ts"
ffmpeg -i "$1"$i.*4 -c copy -bsf:v h264_mp4toannexb -f mpegts "$1"$i.ts
list="$list|$1"$i".ts"
done

echo "##########################################"
list=`echo "$list" | cut -c 2-`
echo "concat of $list"
ffmpeg -i "concat:$list" -c copy -bsf:a aac_adtstoasc "$1""F.mp4"
rm -f "$1"*.ts

# let user manually remove source files after checks
# EOF