A Digital Beep

When you don't have a Speaker/Bell, or you can't make quite make it work, and you want a beep!

It seems some devs have been a bit over zealous in trying to get rid of the system beep. Apparently, some users have been loudly complaining about their systems playing loud beeps. So they have thrown the baby out with the bath water. And now users who need the system beep do not seem to have it anymore.

The traditional method, to trigger the bell sound on a system beep event, was usin pcspkr or snd-pcsp kernel modules. It seems quite a lot of users have lost this functionality during system updates. There seem to be multiple workarounds of workarounds floating around to resolve this issue. They seem to work for some, but not for many.

If you can, it is best to try get either pcspkr or snd-pcsp to work, as the system beep is an integrated event. You can hear the beep anywhere you want, including the console and terminals. The beep volume can be controlled from your audio mixer. You can increase, decrease, or mute the beep volume. That is how it used to be, and that is how it should have been.

Unfortunately, we seem to have quite a lot of trigger happy devs lately. In their eternal quest to keep adding yet more features and bumping up versions, they lose sight of core functionality and stability. Personally, I would rather have stable (even if old) reliable systems, than use bleeding edge new systems filled with tons of new features and even more bugs. In this process, they seem to be cannibalising what they have been handed over from previous generations to maintain.

But I guess, we are where we are.. and we try to make the best of what we have.

A digital beep could be a useful alternative. In this case, an audio file sounding like a bell masquerades as the pc-speaker bell at each system beep. In a nutshell, an audio player plays an audio file, at every system beep event.

The caveat is that depending on the method used, a digital beep is restricted to certain environments only. The method used below will only work within X, not on the console or any tty or anywhere outside X.

Read on for what is required. You can customise, or replace most of the bits with something else.

Kernel config:

Since we will not use pcspkr or snd-pcsp, we might as well remove them from the kernel, or atleast mask them. No need to carry excess baggage. No point in having things we can't/won't use.

# vi /etc/modprobe.d/blacklist.conf
blacklist pcspkr
black snd-pcsp

Check your kernel config for INPUT_BEEP. If not, add them and recompile your kernel. You will need to reboot for the new kernel to take effect.
$ grep BEEP /boot/config-`uname -r`
CONFIG_SND_HDA_INPUT_BEEP=y
CONFIG_SND_HDA_INPUT_BEEP_MODE=1

It is enabled in the default kernel configs of gentoo, debian, ubuntu, and arch linux.

Packages required:
1. sound-theme-freedesktop
2. vorbis-tools
3. xkbevd

sound-theme-freedesktop: A standard minimal freedesktop.org sound theme.
This package installs a set of sound files in /usr/share/sounds/freedesktop directory. One of those audio files called bell.oga simulates a digital beep.

vorbis-tools
This package contains the ogg123 audio decoder/player, which can play .oga sound files from a sound-theme.

$ man ogg123
ogg123 reads Ogg Vorbis audio files and decodes them to the devices specified on the command line. By default, ogg123 writes to the standard sound device, but output can be sent to any number of devices. Files can be read from the file system, or URLs can be streamed via HTTP.

xkbevd: XKB event daemon
We run this as a background service to check for bell events, and trigger ogg123 to play bell.oga.

$ man xkbevd
The xkbevd event daemon listens for specified XKB events and executes requested commands if they occur. The configuration file consists of a list of event specification/action pairs and/or variable definitions.

The default configuration file is ~/.xkb/xkbevd.cf, which needs to be created.

$ vi ~/.xkb/xkbevd.cf
soundDirectory="/usr/share/sounds/"
soundCmd="ogg123 -q"

Bell() "freedesktop/stereo/bell.oga"

This is pretty much the standard configuration.

We could open this up, and use any other audio file and any other media player. One thing to consider would be the impact of using large audio files and/or large audio players. We don't really want our system to freeze at every single bell event, while bloatwares load.

Identify your environment, to auto-start the XKB event daemon, according to your DE (Desktop Environment) or WM (Window Manager).

In my case, I login at the console and startx. I added the following line to my startup file.

$ vi ~/.xinitrc
xkbevd -bg
exec i3

There are a few more lines in that file. But those are the last two lines.

Ok, we have pretty much finished up. Now, we need to check whether these settings take effect.

If you had to recompile your kernel, you need to reboot. If you didn't, you need to logout and login, to verify the daemon auto-start.

May the beep be with you!

i3 wm

I've been hearing about i3 Window Manager for a while now, and had been waiting to have a go. I finally did.

i3wm.org
i3 User Guide

All the major advantages are listed on the homepage itself. What I particularly like:
"Don’t be bloated, don’t be fancy (simple borders are the most decoration we want to have)."

For now I am making it my home. I don't need any fancy distracting frills. The only thing I seem to be missing is Alt+Tab, as I keep hitting it.

You can have a really beautiful desktop, but how long are you going to look at it, before you open some windows which cover most of your desktop? As for me, I usually have all windows maximised.

i3 has three layouts - split ($mod+e), stacking ($mod+s), and tabbed ($mod+w). I particularly like the tabbed layout maximising screen estate use on small laptop screen. (Auto)Hide the statusbar, and or full-screen ($mod+f) your windows.

$mod+Enter will open a new terminal window in your chosen layout. You can change layouts anytime.
$mod+Shift+q will close your active window.
$mod+Shift+e will exit i3.

Armed with this basic knowledge, we can start exploring i3.

It is a very simple install - three packages - i3 + i3status and dmenu.

On first run, i3 will prompt you and create it's config in ~/.config/i3/config.

Below are my config files.

$ cat ~/.xinitrc
#!/bin/sh
setxkbmap -option terminate:ctrl_alt_bksp
exec i3

$ cat ~/.config/i3/config
set $mod Mod4

#font pango:monospace 8
font pango:DejaVu Sans Mono 8

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

hide_edge_borders both
workspace_layout tabbed
workspace_auto_back_and_forth yes
force_display_urgency_hint 5000

bindsym $mod+Shift+c reload
bindsym $mod+Shift+r restart
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"

bindsym $mod+Shift+q kill
bindsym $mod+Return exec i3-sensible-terminal

#bindsym $mod+d exec dmenu_run
bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right

bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right

bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

bindsym $mod+h split h
bindsym $mod+v split v

bindsym $mod+f fullscreen toggle

bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

set $workspace1 "1 "
set $workspace2 "2 "
set $workspace3 "3 "
set $workspace4 "4 "
set $workspace5 "5 "
set $workspace6 "6 "
set $workspace7 "7 "
set $workspace8 "8 "
set $workspace9 "9 "
set $workspace10 "10 "

bindsym $mod+1 workspace $workspace1
bindsym $mod+2 workspace $workspace2
bindsym $mod+3 workspace $workspace3
bindsym $mod+4 workspace $workspace4
bindsym $mod+5 workspace $workspace5
bindsym $mod+6 workspace $workspace6
bindsym $mod+7 workspace $workspace7
bindsym $mod+8 workspace $workspace8
bindsym $mod+9 workspace $workspace9
bindsym $mod+0 workspace $workspace10

bindsym $mod+Shift+1 move container to workspace $workspace1
bindsym $mod+Shift+2 move container to workspace $workspace2
bindsym $mod+Shift+3 move container to workspace $workspace3
bindsym $mod+Shift+4 move container to workspace $workspace4
bindsym $mod+Shift+5 move container to workspace $workspace5
bindsym $mod+Shift+6 move container to workspace $workspace6
bindsym $mod+Shift+7 move container to workspace $workspace7
bindsym $mod+Shift+8 move container to workspace $workspace8
bindsym $mod+Shift+9 move container to workspace $workspace9
bindsym $mod+Shift+0 move container to workspace $workspace10

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym j resize shrink width 10 px or 10 ppt
        bindsym k resize grow height 10 px or 10 ppt
        bindsym l resize shrink height 10 px or 10 ppt
        bindsym semicolon resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keys
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

bindsym $mod+r mode "resize"

bar {
 status_command nice -n19 i3status -c ~/.config/i3/i3status.conf
 position top
 colors {
  statusline #55BB55
 }
}

bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -q set Master 2+
bindsym XF86AudioLowerVolume exec --no-startup-id amixer -q set Master 2-
bindsym XF86AudioMute exec --no-startup-id amixer -q set Master toggle

bindsym XF86MonBrightnessUp exec xbacklight -inc 20
bindsym XF86MonBrightnessDown exec xbacklight -dec 20

for_window [class="Gimp"] floating enable

assign [class="Geany"]  $workspace1
assign [class="QupZilla"] $workspace2
assign [class="Opera"]  $workspace2
assign [class="Firefox"]  $workspace2
assign [class="Spotify"] $workspace10
assign [class="spotify"]  $workspace10

exec --no-startup-id "wpa_gui -t"
exec --no-startup-id "volumeicon"

The default i3status config is ~/.config/i3status/config, but I wanted to keep all my i3 stuff together. There's not much there.. just two files.

$ cat ~/.config/i3/i3status
# i3status configuration file.
# see "man i3status" for documentation.

# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!

general {
 output_format = "i3bar"
 colors = true
 interval = 5
 separator = ""
 color_good = "#55bb55"
 color_bad = "#bb0000"
 color_degraded = "#bbbb00"
}

order += "wireless _first_"
#order += "ethernet _first_"
order += "disk /"
#order += "cpu_temperature 0"
order += "cpu_usage"
order += "load"
order += "volume master"
order += "battery 0"
order += "time"

wireless _first_ {
 format_up = " %bitrate %quality %frequency %essid"
 format_down = ""
}

ethernet _first_ {
 ## %speed requires root privileges
 format_up = "E %ip %speed"
 format_down = "E"
}

disk "/" {
 format = " %avail"
 prefix_type = "custom"
 low_threshold = "1"
 threshold_type = "gbytes_avail"
}

cpu_usage {
 format = " %usage"
}

load {
 format = " %1min"
}

cpu_temperature 0 {
 format = "%degrees °C"
 path = "/sys/devices/platform/coretemp.0/temp1_input"
}

volume master {
 format = " %volume"
 format_muted = "♪ %volume"
 device = "default"
 mixer = "Master"
 mixer_idx = 0
}

battery 0 {
 #format = "%status %percentage %remaining %emptytime %consumption"
 format = "%status %percentage %consumption %remaining"
 format_down = ""
 integer_battery_capacity = "true"
 hide_seconds = true
 status_chr = ""
 status_bat = ""
 status_full = "☻"
 path = "/sys/class/power_supply/BAT%d/uevent"
 low_threshold = 10
 threshold_type = percentage
}

time {
 format = " %b %d %a %R"
}

ref: i3wm Jump Start, by Alex Booker

gentoo portage

ref: http://wiki.gentoo.org/wiki/portage

Gentoo is Portage. Portage is Gentoo.

$ cat /etc/portage/make.conf
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="i686-pc-linux-gnu"

CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3"
INPUT_DEVICES="libinput"
VIDEO_CARDS="intel i965 i915"
ALSA_CARDS="hda-intel"
LCD_DEVICES=""

LINGUAS="en_GB"
L10N="en-GB"
PYTHON_TARGETS="python2_7"

MAKEOPTS="-s -j4"
EMERGE_DEFAULT_OPTS="--ask --tree --jobs=2"
PORTAGE_NICENESS="19"

USE="-gnome -ipv6 -nls -systemd threads"
ACCEPT_KEYWORDS="~x86"

$ cat /etc/portage/package.mask
sys-apps/systemd
sys-fs/udev
dev-lang/python:3.4
dev-lang/python:3.5

$ cat /etc/portage/profile/use.mask
-input_devices_libinput

I also replace those package.* directories with files of the same name. For eg,

# cd /etc/portage/
# mv -vi package.use{,.gentoo}
# cat package.use.gentoo/* >>package.use

The currently active USE flags, are the sum of all profiles.
# emerge --info | grep ^USE

View all portage settings.
# emerge --info

Ensure portage settings as you want, or you will recompile everything all over again for each change. Nevertheless and frustratingly, we will probably do so many times over ;-)
ref: http://wiki.gentoo.org/wiki/handbook:x86/Working/Portage#Updating_the_system
# emerge --deep --changeduse @world
# emerge --depclean --ask
# revdep-rebuild

That last command is from gentoolkit, not part of core gentoo. Another useful tool is eix.

# emerge --ask app-portage/{gentoolkit,eix}

ref: http://wiki.gentoo.org/wiki/world_set_(Portage)
emerge -auvND world does not upgrade everything.
emerge -auvND --with-bdeps=yes world will attempt to upgrade build-time dependencies. run once a month or so.
emerge -e system maybe once or twice a year.

dash shell

dash is more efficient than bash in all respects, except perhaps for interactive use. and i always replace system default and login shells with dash.

$ cd /bin
# ln -sf dash sh

# usermod -s /bin/sh root

i faced a particular problem in gentoo.

after the rebooting the just installed system, i couldn't login as root to finish installing the rest of the system. i finally gave up and trashed the system.

i wiped the disk clean, and re-installed yet again from scratch. all i wanted to check was that i could login. what's the purpose of installing a fabulous system, if you can't login? so i left most other install tasks/config for later. i could successfully login!

now i moved on with what i normally do to my systems, just to finish up and find that i could not login!

i rememembered that the last thing i did was to replace my system default and login shells with dash. so i undid that. bash became the default again. and i could login!

the problem was isolated to dash as login shell!

further troubleshooting narrowed down the issue to login shell only. gentoo was fully working with dash as the system default shell.

my research led me to the ever helpful gentoo forums, and this post.

indeed, gentoo does not list /bin/dash in /etc/shells. problem solved!

# echo /bin/dash >>/etc/shells

gentoo second install x86 btrfs debian

Now that my Gentoo Phase 2 has been put on hold for the near future, I have to satisfy this itch to install gentoo on my main laptop. Having it on my primary rig, would allow me to use it more often than pulling out my backup system.

My blind first attempt, at a gentoo install, gave me a lot of confidence in the gentoo community. This second attempt substantially lessens the time/aggro I spent previously installing gentoo.

I have significantly pruned the install path from my previous gentoo install process, removing many distractions. I could have just copied over those btrfs subvolumes, but I wanted to do this.

Beware if you want systemd, don't just blindly follow this.

Install Environment

This time I start from my running debian. I have a working environment, networking and x-browser. No faffing about with any install disks etc. And I can continue working, while gentoo is crunching my cpu/disk.

You may follow this, installing from your own distro.

Partitions

I like btrfs - cow, subvolumes, snapshots. I have many subvolumes on my os partition. I create new ones for this gentoo install, and use a few other existing ones.

# mount -L os /media/os
# btrfs subvolume create /media/os/@gentoo32
# btrfs subvolume create /media/os/@portage

The gentoo handbook refers to /mnt/gentoo. So we mount our subvolumes there.

# mkdir -p /mnt/gentoo
# mount -L os -o defaults,relatime,compress=lzo,subvol=@gentoo32 /mnt/gentoo/

I will use the other subvolumes after this install completes to my satisfaction, as I don't want any accidents. This also keeps it simple and straightforward, with everything on one subvolume.

Stage3

Download, verify and extract the latest gentoo stage3. I use /tmp as working directory, as we won't need those files later.

$ cd /tmp
$ wget http://distfiles.gentoo.org/releases/x86/autobuilds/current-install-x86-minimal/stage3-i686-{yyyymmdd}.tar.bz2
$ wget http://distfiles.gentoo.org/releases/x86/autobuilds/current-install-x86-minimal/stage3-i686-{yyyymmdd}.tar.bz2.DIGESTS
$ sha512sum -c stage3-*.tar.bz2.DIGESTS
# tar --numeric-owner --xattrs -xvapf stage3-*.tar.bz2 -C /mnt/gentoo/

I downloaded a 228M file, which extracted 860M. So be patient..

Filesystems

mount required psuedo filesystems
# mount -o bind /proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --make-rslave /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount --make-rslave /mnt/gentoo/dev
# mount --rbind /run/shm /mnt/gentoo/run/shm

Anything outside chroot will be inaccessible.

# cp -L /etc/resolv.conf /mnt/gentoo/etc/

Enter the chroot

# chroot /mnt/gentoo /bin/bash
# source /etc/profile
# export PS1="(chroot) $PS1"

my favourite editor :-)
# ln -s /bin/busybox /usr/local/bin/vi

Portage
ref: gentoo portage

Do yourself a favour, and ignore everything the handbook says about portage.. for now!
Learning everything about portage is really really useful, but not during installation. Particularly, if you are new to gentoo, or still a newbie.

Install the latest portage snapshot, with all the above settings.
emerge-webrsync -q

/usr/portage is created during this first run. Ignore those warnings..

This will take time.. be patient ;)

News

$ man news.eselect
$ eselect news list
$ eselect news read [number]

Action the relevant news items. Do your own research though. As I got news items too old, and although relevant, not completely correct either.

Timezone

$ ls /usr/share/zoneinfo
# echo "Europe/London" >/etc/timezone
# ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

Locales

$ cat /etc/locale.gen
en_GB.UTF-8 UTF-8

If more than one locale, each should be on a separate line. Atleast one should be UTF-8.

# locale-gen
$ locale -a
$ eselect locale list
# eselect locale set {number}

$ cat /etc/env.d/02locale

Reload environment, after changes.
$ env-update && source /etc/profile && export PS1="(chroot)$PS1"

Kernel

No kernel is installed. We make our own.
ref: gentoo kernel

I moved the kernel section up ahead this time. While the kernel compiles, we continue the rest of the install..
on another terminal :) Enter chroot, and reload environment.

/etc/fstab

$ cat /etc/fstab

Networking

Gentoo utils are best in class. We will use netifrc. Busybox udhcpc is used automatically for all configured interfaces.

Configure interfaces
# ln -s /etc/conf.d/net.{lo,wlp3s0}

I need iw and wpa_supplicant.
ref: wpa_supplicant
# emerge --ask net-wireless/{wpa_supplicant,iw}

vi /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
update_config=1

# wpa-passphrase {ssid} {password} >>/etc/wpa_supplicant/wpa_supplicant.conf

# vi /etc/conf.d/hostname
hostname="{hostname}"

# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost {hostname}
Misc

keyboard
# vi /etc/conf.d/keymaps

root passwd
# passwd

Bootloader

No bootloaders to be installed in this instance, as we use an existing one. I just add another entry in wheezy's /etc/grub.d/

menuentry "@gentoo32/vmlinuz" {
  set gfxpayload=auto
  set rtlbl=os
  set subvol=@gentoo32
  search --no-floppy --set root --label $rtlbl
  set bootoptions="root=LABEL=$rtlbl rw rootfstype=btrfs rootflags=defaults,noatime,compress=lzo,subvol=$subvol quiet"
  linux /$subvol/vmlinuz $bootoptions
  initrd /$subvol/initrd.img
}

filesystem:
ensure you have the corresponding filesystem tools.

# emerge --ask sys-fs/btrfs-progs

Don't forget the other terminal.. and finish installing the kernel and/or initramfs!

Exit the chroot

# exit
# reboot

most popular posts