Tagged: how_to

Building My Work Environment (Part 4)

Part 4 - De-Uglifying i3

There are many sites offer themes/themers for i3, like unix121's themer. But I like clean and simple, so I changed just a handful of components.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

gtk2 Theme

I imported my old gtk2 theme, Morning Glory from Openbox days. This theme can be applied using lxappearance.$ tar -xzvf MorningGlory.tar.gz -C ~/.themes/ ... $ lxappearance

Icons

I still use Faenza icon set. I recently found out that this icon set can be downloaded and installed from slackbuilds.org


Font Awesome Fonts/Icons

i3pystatus I installed in the Part 3 uses icons to display each component, like CPU and memory. For that, font awesome needs to be installed. The latest version at the time of this writing is 5.0.10. Download a zip file, unzip it, and copy otf files from the use-on-desktop folder to system appropriate directory.$ unzip fontawesome-free-5.0.10.zip ... $ cd fontawesome-free-5.0.10/use-on-desktop/ # cp *.otf /usr/share/fonts/OTF # mkfontdir /usr/share/fonts/{TTF,OTF} # mkfontscale /usr/share/fonts/{TTF,OTF} # fc-cache -fv Restart X

To check if the fonts were properly installed, run fc-list:$ fc-list | grep -i awesome ...

Ricty Font

Ricty is Japanese True Type font based on Inconsolata and Circle M+ 1m, optimized for the programming usage. Here is some benefits of using the font:

  • Use Inconsolata for the Latin character glyphs and "Circle M+ 1m" font for other glyphs.
  • Adjust the width of full-width and normal-width character glyphs to 2:1 ratio exactly full and half.
  • Design the comma, period, colon, semicolon and bracket character glyphs to differentiate each other clearly to prevent confusions.
  • Design the high visibility p-sound sign attached Kana character glyphs.
  • Design the En-dash and Em-dash glyphs show them as the broken line to prevent input failures for LaTeX.
  • It shows Em-size space as "box" character because Em-size space often prevents debugging since users usually miss it. With Ricty Diminished font, users can find and fix it easily.

The instruction on how to build Ricty is from this site.

Bash Environment

I changed the style and color of PS1 in .bashrc. PS1='\[\e[38;5;106m\]\A \[\e[38;5;210m\]\u\[\e[38;5;229m\]@\[\e[38;5;220m\]\h\[\e[38;5;252m\][\[\e[38;5;69m\]\w\[\e[38;5;252m\]]\n\[\e[47m\]\[\e[38;5;232m\]$\[\e[00m\] '


=====
~/.bashrc
=====

Color Scheme for ranger

ranger is a text-based file manager with vi/vim key-bindings. Since it's key stroke based, it's perfect for i3. I like my default color scheme. But you can change the color scheme by ~/.config/ranger/colorschemes/.
For syntax highlighting in ranger, I use highlight.


=====
~/.config/ranger/*
=====

Color Scheme for urxvt

The color scheme for urxvt is controlled from .Xresources. I'm currently using gruvbox.

=====
~/.Xresources
=====

rofi

rofi is a window switcher, application launcher, and dmenu replacement, currently maintained by Dave Davenport. It's lightweight and highly customized. My rasi theme file, dark_elements.rasi, and rofi config file are availble.


=====
~/.config/rofi/*
=====

i3lock

I created a bash file to take a screenshot, blur that image, insert a lock icon, and apply it to i3lock.


=====
~/Scripts/i3lock/lock_blur_i3.sh
~/Scripts/i3lock/lock_red.png
=====

In next article, let's talk about displaying Japanese characters in terminal.

That's all!
-gibb

Building My Work Environment (Part 3)

Part 3 - Oh, what's that Window Manager?

Openbox used to be my de facto window manager for my systems for years. You can see some of my posts related to Openbox here. I have nothing but praises for its lightweight and solid performance (Not to mention it's highly customizable).

Then, I learned about Tiling window manager by chance. Tiling WM is designed to arrange windows in a way that they don't overlap each other. Also, it supports key-bindings to operate around keystrokes instead of using a mouse. That reminded me of vi/vim editor. Those facts piqued my interest.

I first started using Awesome Window Manager because it was a tiling window manger but also supported the floating option, which somewhat gave me a peace of mind. Awesome wm was highly configurable from a configuration file written in lua language. I quickly got around and configured it the way I wanted. However, a few months after, I noticed some keybindings stopped working and/or didn't behave the ways they should.

Then, I moved onto i3 window manager. It was next logical thing to try this wm as I read so many positive inputs about it. No regrets. It's easier to configure than Awesome wm because its configuration file is plain text, and it just worked. I've been using it a little more than a few months but I don't think I could go back to Awesome wm or stacking/floating window manager like Openbox ever again!

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Installation:

Installation of i3wm isn't that difficult with Slackware. Go to slackbuilds.org, download all dependencies, and install them one by one.... Installation of dependencies ... $ tar -xzvf i3.tar.gz i3/ i3/slack-desc i3/README i3/i3.SlackBuild i3/i3.info i3/doinst.sh i3/xinitrc.i3 $ mv i3-4.15.tar.bz2 i3/ # cd i3/ # ./i3.SlackBuild ... Slackware package /tmp/i3-4.15-x86_64-1_SBo.tgz created. # installpkg /tmp/i3-4.15-x86_64-1_SBo.tgz ... Executing install script for i3-4.15-x86_64-1_SBo.tgz. Package i3-4.15-x86_64-1_SBo.tgz installed.

At the beginning, I referred i3 like vi/vim. It's just like that. If you know right key combinations, your productivity would increase. But if you are not familiar with it, it's just so hard to deal with. In my humble opinion, although its learning curve is steep, it's worth learning how to properly use it.

To set i3 as your default windows manager, you'd need to run xwmconfig. $ xwmconfig

Config File:

i3's config file is located at ~/.config/i3/config, and it's a plain text file. It should be fairly easy to understand because of all the comments there. One thing you do need to remember is to reload the config file with $Mod+Shift+r each time the file has been modified.
=====
~/.config/i3/config
=====

Status Bar:

By default, i3 does not offer a status bar unless you install one. I tried with i3blocks and configured it with mpd/ncmpcpp support and everything I wanted to show in my status bar on my notebook with Debian stretch; however, to install i3blocks on Slackware, you need to go through ridiculous number of dependencies. For that reason, I gave up on installing i3blocks. Instead, I installed i3pystatus. i3pystatus was so easy to set up and manage it because each piece is a module, and it didn't take me long to configure it as I wanted.

Before i3pystatus can properly display, some python modules need to be installed: $ pip3 install --upgrade pip ... $ pip3 install netifaces \ > psutil \ > colour ... $

The i3pystatus version I downloaded from slackbuilds.org is 3.35. I'm not sure if this problem only applies to this version but when memory usage is displayed with {used_mem}, it displays a negative value. After reading up on different forums, I figured out that its source code for mem.py did not support newer version of psutil. Within the code, to get the value of used memory, it was subtracting cached and buffers values from used value. This was ok for psutil version before 4.4.0. With newer psutil (> 4.4.0), getting the used value itself was good enough, I guess.

To prove my point, this is what's going on: $ python3 >>> import psutil >>> psutil.__version__ '5.4.5' >>> mem = psutil.virtual_memory() svmem(total=...) >>> print(mem.used - mem.cached - mem.buffers) <== This is what's done in the code -311427072 <== Gives a negative value >>> print(mem.used) <== For newer psutil version, this is all you need 301985792

Now, we need to edit the source code to take care of newer version for psutil. 1) Change 2nd line from this:from psutil import virtual_memory to: import psutil 2) On line 45 and 46, there is a piece of code to get used memory. That should be changed from:memory_usage = virtual_memory() used = memory_usage.used - memory_usage.cached - memory_usage.buffers to:memory_usage = psutil.virtual_memory() if psutil.version_info < (4, 4, 0): used = memory_usage.used - memory_usage.cached - memory_usage.buffers else: used = memory_usage.used This should take care of displaying a negative value for used memory in i3pystatus.

=====
~/.config/i3/i3pystatusconf.py
=====

Screen Lock:

I use i3lock to lock the screen. It's simple and customizable.

Shutdown, Reboot, and Logout:

The official way of getting out of i3 is to press $Mod+Shift+e simultaneously. This will show a message bar on top of the screen. Then click on yes, exit i3 to exit. I found this step a bit cumbersome. I could type sudo /sbin/shutdown -h now in a terminal but I'd need to open one if I'm in say web browser workspace. So, I created a i3 mode to handle key combinations to logout, lock screen, reboot, or shutdown (referenced Arch Linux Wiki).

For this to work, sudoer needs to be enabled for a regular user to run the shutdown or reboot command.# visudo ------------------------ [user_name] ALL=NOPASSWD: /sbin/shutdown,/sbin/reboot

In next article, let's talk about changing the look and feel of i3 window manager.

That's all!
-gibb

Getting ‘heroku’ installed with Termux on Android

I have this personal project where I need to regularly update PostgreSQL database from a dump file so that users can view the most up-to-date information every week. My web hosting company, ICD Soft, offers MySQL but not PostgreSQL. I could convert a PostgreSQL dump to MySQL but doing this every time may be time consuming and there is a chance where someone who has no knowledge of database might need to handle this task if I'm not available, so converting was out of questions.

Another option was to look for a free service that offers managing a remote PostgreSQL server. Then, I found Heroku. It seems to offer what I want. So, I decided to give it a try.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

As usual, I do most of developing work on my cell phone (Samsung Note 8), I tried to install heroku on Termux. Installation was fairly simple after tweeking a bit.

PHP Installation:

First thing first, I'll be using PHP to develop my site with heroku. So, PHP needs to be installed on Termux:$ apt-get update $ apt-get install php

Composer Installation:

Secondly, composer (PHP dependent management tool) needs to be installed:$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" $ php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" $ php composer-setup.php $ php -r "unlink('composer-setup.php');"

Standard Heroku Installation:

Now follow the instruction from Heroku documentation site with some tweeks for Termux: $ wget http://cli-assets.heroku.com/heroku-cli/channels/stable/heroku-cli-linux-x64.tar.gz -O heroku.tar.gz $ tar -xvzf heroku.tar.gz -C heroku $ mv heroku /data/data/com.termux/files/usr/lib/heroku $ ln -s /data/data/com.termux/files/usr/lib/heroku/bin/heroku /data/data/com.termux/files/usr/bin/heroku

Tweekings 1 - heroku script:

Installation of Heroku is now done, but it doesn't work as is because I just installed Linux version of tarball in Termux on Android. If heroku is executed now, it'll give you some error messages:$ heroku bash: /data/data/com.termux/files/usr/bin/heroku: /usr/bin/env: bad interpreter: No such file or directory

This is because the heroku script is pointing to /usr/bin/env for bash. This needs to be changed to correct path for Termux:$ cd /data/data/com.termux/files/usr/lib/heroku/bin/ $ vim heroku #!/usr/bin/env bash set -e ... Change the first line from #!/usr/bin/env bash to #!/data/data/com.termux/files/usr/bin/env bash, and save the file.

Tweekings 2 - node binary:

The tarball downloaded contains node.js binary for auto update but this binary doesn't seem to work in Termux and it would give an Exec format error:$ heroku /data/data/com.termux/files/usr/bin/heroku: line 29: /data/data/com.termux/files/usr/lib/heroku/bin/node: cannot execute binary file: Exec format error

To work around this problem, I installed node.js separately and made a symlink. This seemed working and no more Exec format error:$ apt-get install nodejs ... $ cd /data/data/com.termux/files/usr/lib/heroku/bin $ mv node node.old $ ln -s ../../../bin/node node $ heroku --version heroku-cli/6.15.31-958455a (android-arm64) node-v8.10.0 $ heroku login Enter your Heroku credentials: Email: *** Password: *** Logged in as *** $

voilĂ , logged in successfully.

That's all!
-gibb

Building My Work Environment (Part 2)

Part 2 - Getting Some Utilities Installed

Now, we've got a base system configured and ready to go. It's time to install some useful utilities.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Here is the list of items to be instaled.

File Manager:
  • pcmanfm
  • ranger
  • highlight (for ranger)
  • My customized ranger/rc.conf (~/.config/ranger/)

Music:
  • cmus

Terminal:
Text Editor:
  • nvim
  • My customized nvim/init.vim (~/.config/nvim/)

Virtualization:
  • virtualbox-kernel
  • virtualbox

Web Browser:
  • chromium

Others:
  • python3
  • scrot - Command line screen capture

The above list may grow in the future but these are the absolute minimum software that I need to do my daily tasks.

All of these can be downloaded from Slackbuilds.org, and follow the usual procedure to get them installed.

Now move onto the next step to install/configure my favorite window manager.

In next article, let's talk about my favorite window manager, i3.

That's all!
-gibb

Building My Work Environment (Part 1)

Part 1 - Base System

I have been a long time Slackware Linux user, probably since Slackware 9 or so. Because of its UNIX-like architecture and stability, Slackware has always been the main OS for my workstation (although I do distro hoppings on my laptop among Debian, FreeBSD, and Arch Linux).

This is just my notes for a list of steps/software I need to install to create my work environment from fresh install of Slackware.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Partition Scheme:

On my current system, I have 16GB of RAM. So, theoretically, I don't think I need a swap partition; however, just in case my system goes haywire, I reserve 1GB of swap partition.

/dev/sda1 - swap (1GB)
/dev/sda2 - / (around 80GB)
/dev/sda3 - /backup (Rest of space)

Installation of Slackware:

Nothing needs to be noted. Follow its instruction.

Post Installation:

After rebooting the system, there are some tasks need to be done.

Create a user
A regulsr user to do daily tasks. # adduser ... follow the instructions ...

Switch to a generic kernel
Run the following script to output the mkinitrd command with customized options. In my case it was below: # /usr/share/mkinitrd/mkinitrd_command_generator.sh # # mkinitrd_command_generator.sh revision 1.45 # # This script will now make a recommendation about the command to use # in case you require an initrd image to boot a kernel that does not # have support for your storage or root filesystem built in # (such as the Slackware 'generic' kernels'). # A suitable 'mkinitrd' command will be: mkinitrd -c -k 4.4.14 -f ext4 -r /dev/sda2 -m usb-storage:ehci-hcd:ehci-pci:xhci-pci:ohci-pci:xhci-hcd:uhci-hcd:hid:usbhid:i3c-hid:hid_generic:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jdb2mbcache:ext4 -u -o /boot/initrd.gz

Update lilo.conf
Since I have LILO installed (the default bootloader of Slackware), its configuration file needs to be updated to boot into the generic kernel. But first run below command to output example sections that need to be updated: # /usr/share/mkinitrd/mkinitrd_command_generator.sh -l /boot/vmlinuz-generic-4.4.14 ... image = /boot/vmlinuz-generic-4.4.14 initrd = /boot/initrd.gz root = /dev/sda2 label = 4.4.14 read-only ...

While editing /etc/lilo.conf, insert lba32, uncomment compact options, and change the timeout value to 0 (zero):# vim /etc/lilo.conf ... lba32 compact ... timeout = 0 ...

Then, run below command to update LILO:# lilo -v

Black listing nouveau video driver
I have rather old video card from NVIDIA which complains about nouveau video driver during its installation. So, the nouveau driver needs to be black listed before installing the video driver from NVIDIA.

To view the name of video driver:# lspci | grep -i vga 01:00.0 VGA compatible controller: NVIDIA Corporation GF106 [GeForce GTS 450] (rev a1)

Then, download xf86-video-nouveau-blacklist-noarch-1.txz from the extra directory in the source tree:# installpkg xf86-video-nouveau-blacklist-noarch-1.txz ... Package xf86-video-nouveau-blacklist-noarch-1.txz installed.

Run the NVIDIA video driver script that's downloaded from the NVIDIA site:# ./NVIDIA-Linux-x86_64-390.48.run

Download Security Patches from slackware.com:

No need to explain:# mkdir /tmp/patches # cd /tmp/patches # wget ftp://ftp.slackware.com/pub/slackware/slackware64-14.2/patches/packages/*.txz ... # upgradepkg *.txz

In next article, let's talk about installing other utilities.

Things To Be Installed:

Fonts:
Icons:
  • Faenza (Slackbuilds.org)

File Manager:
  • pcmanfm
  • ranger
  • highlight (for ranger)
  • My customized ranger/rc.conf (~/.config/ranger/)

Music:
  • cmus

Terminal:
Text Editor:
  • nvim
  • My customized nvim/init.vim (~/.config/nvim/)

Themes:
Version Control:
  • git

Virtualization:
  • virtualbox-kernel
  • virtualbox

Web Browser:
  • chromium

Window Manager:
  • i3
  • i3status
  • i3pystatus
  • My customized i3/conf (~/.config/i3/)
  • My customized i3pystatusconf.py (~/.config/i3/)

Others:
  • rofi - Replacement for dmenu
  • scrot - Command line screen capture
  • My customized rofi/config (~/.config/rofi/)

That's all!
-gibb