Archive

Archive for November, 2018

You can open a markdown (.md) file in Okular

November 29, 2018 Leave a comment

Today I found out by accident that you can open a markdown file (.md) with okular. okular was just a PDF viewer for me. The .md file is nicely rendered and you can convert it to PDF or you can print it. Awesome!

Categories: linux Tags: , , , ,

[shell] How to tell your distro version?

November 28, 2018 Leave a comment

Problem
I use two different Linux distros, Ubuntu and Manjaro. Both of them are great. My shell resource files (previously .bashrc, now .zshrc) are shared via Dropbox. However, sometimes I would like to differentiate my Ubuntu and Manjaro settings, within the same resource file. How to do that?

Solution
Here is what I use:

# DESKTOP_SESSION is "ubuntu" (for Ubuntu) or "xfce" (for Manjaro)
if [[ "$DESKTOP_SESSION" == "ubuntu" ]]; then
  alias files='dpkg-query -L'
else
  alias files='pacman -Ql'
fi 

Older solution
Before finding the environment variable DESKTOP_SESSION, I used this:

# return "ubuntu", "manjaro" (without quotes)
get_distro_name() {
  cat /etc/os-release | grep "^ID=" | cut -d= -f2
}

# usage:
# if [[ $(get_distro_name) == "ubuntu" ]]; then
#   alias files='dpkg-query -L'    # ubuntu
# else
#   alias files='pacman -Ql'       # manjaro
# fi
Categories: shell Tags: , , , , ,

Steam client on Ubuntu 18.04

November 26, 2018 Leave a comment

Problem
Steam stopped working. At the end of an update process it complained that “steamui.so” was missing.

Solution
I found the solution here. In short:

First, delete steam:

sudo apt remove steam

Execute this:

sudo dpkg --add-architecture i386

Restart the machine. Then, install these packages:

sudo apt-get install wget gdebi libgl1-mesa-dri:i386 libgl1-mesa-glx:i386 libc6:i386

Download the steam package:

wget http://media.steampowered.com/client/installer/steam.deb

And install it:

sudo gdebi steam.deb

After this, steam started normally for me.

Hero of the Kingdom 2 patch
The game “Hero of the Kingdom 2” didn’t want to start. I got the error “access violation”. I found the remedy here.

It seems this problem is related to the Intel driver. I have an integrated Intel video card.

The solution in short: download the driver http://de.archive.ubuntu.com/ubuntu/pool/main/m/mesa/libgl1-mesa-dri_11.2.0-1ubuntu2_i386.deb , extract it, and replace the file /usr/lib/i386-linux-gnu/dri/i965_dri.so with the one from the archive. Of course, don’t forget to make a backup of the original file.

[nim] using the xterm-256 colors in the terminal

November 25, 2018 Leave a comment

Problem
Most terminals support the xterm-256 extension, which allows you to use 256 colors in your terminal. But how to use these colors from Nim?

Solution
See https://gist.github.com/jabbalaci/700fd51757b1c0a1edac4ef61946bc3d for a demo. Screenshot: here.

Links
I found the original ZSH version here. I took this code and rewrote it in Nim.

Categories: linux, terminal Tags: , , ,

number of lines and columns of your terminal

November 16, 2018 Leave a comment
$ tput lines
22
$ tput cols
165

Of course, the values depend on your own settings.

I found it in the script snowjob.sh, which adds snowflakes to your terminal. Really cool.

Related animated short film: Operation White Widow (2011).

Update
In Nim, there are functions for these in the module terminal. See terminalWidth and terminalHeight.