RSS Feed

Category Archives: linux

Dell Vostro 5459 hibernation


In the previous post (1 year ago), I mentioned the hibernation issue. I believed that it was related to the NVidia graphic card. Related forum can be found here.

But these few days, I notice that whenever I shut down the laptop, it will show the systemd messages. Previously, if I did suspend my laptop, then resume, then shut down will show only black blank screen, until the power off. I believe that the graphic card issue is being fixed with the recent update.

I am now using linux-lts 4.9.13-1 and nvidia-dkms 378.13-2

Linux no sound after boot into Windows


Just now was trying to boot into Windows, by plugged in the HDMI cable, which supports for video only. But then, I rebooted into Linux without plugged out the HDMI cable. Then, it caused no sound in Linux.

Try 1: I killed the pulseaudio, then delete the ~/.config/pulse, and rebooted Linux. Failed.

Try 2: Run alsamixer, turned on everything, and do Try 1 again. Failed.

Then I guessed it was caused by the HDMI cable, which the Windows may assume there is audio, then caused my computer somehow ouptut the audio through the HDMI, even I rebooted into Linux.

Try 3: Plugged out the HDMI, booted into Windows. I checked the audio in Windows. It plays well. Then rebooted into Linux without plugged in HDMI. Yeah! It works. Passed.

Next level

Then I found that, though the sound works fine, my headphones doesn’t work. Tried out many methods as I asked in forum.

At the end, it is solved by shutdown, and boot again.

Openbox + tint2


Previously I was using Xfce4. Then, because of the heavy working environment, I tried the lighter desktop environment, LXDE. But still, it has some limitations that made me choose to use Openbox window manager only.

Pros and cons of Xfce4

Xfce4 is lightweight comparing to GNOME or KDE. I like it, because of the conventional design like the task manager. Furthermore another thing I like is the “aerosnap” feature like Windows, which I can view the two windows side by side. However, when running Windows in VirtualBox and other applications, I can feel the obvious slowness in the computer. It is really reducing my working performance. That is why I decided to change to LXDE.

Pros and cons of LXDE

LXDE is lighter than Xfce4. So, running a lot of heavy applications does not slow down the computer like Xfce4. But there was one issue I faced. The LXDE pager (workspace) does not allow me to drag and drop the applications to move among the workspaces.

As a result, I decided to use something lighter than Xfce4 and I can drag and drop the applications among the workspaces easily.

Openbox and tint2

I had experienced Openbox with tint2 when I was using my old laptop. Openbox is nice and highly customisable. Tint2 allows me to set number of workspaces, and easily to move the applications to other workspaces. However, tint2 does not have applets or plugins like Xfce4 or LXDE.

There is one feature I need, that is to see CPU usage, so that I know whether there is any application causes high CPU usage. As a result, I installed Conky and display the CPU usage at the corner of the desktop.

Openbox + tint2

Openbox + tint2

Conky

For the Conky, the following is the conky.conf

conky.config = {
    alignment = 'bottom_right',
    background = false,
    border_width = 0,
    cpu_avg_samples = 2,
	default_color = 'white',
    default_outline_color = 'BBBBBB',
    default_shade_color = '444444',
    draw_borders = false,
    draw_graph_borders = false,
    draw_outline = false,
    draw_shades = false,
    use_xft = true,
    font = 'DejaVu Sans Mono:size=1', --by size 1 then only there will have no space after cpugraph
    gap_x = 0,
    gap_y = 2,
    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 = 'desktop',
	own_window_transparent = true,
	own_window_argb_visual = true,
	own_window_argb_value = 255,
    stippled_borders = 0,
    update_interval = 1.0,
    uppercase = false,
    use_spacer = 'none',
    show_graph_scale = false,
    show_graph_range = false,
	double_buffer = true,
	imlib_cache_size = 10,
}

conky.text = [[
	${cpugraph 27,40 000000 FFFFFF -l}
]]

Windows – Linux Edition (opinion only)

Posted on

This is just an opinion, not the fact.

Not long ago, there is an announcement that Windows can run Bash on Ubuntu on Windows. Not only that, there is Windows subsystem for Linux.

Surely, Linux and UNIX have a lot of powerful features, especially developer oriented. That is why Windows has to adopt them. Because they really solves a lot of problems, such as bash and other commands like grep, find, and vi. Cloud computing is emerging, command-line is much more efficient than GUI. Text file for collaborative development is much more efficient (using git) than working on binary file, as you cannot diff and patch.

Since Windows now supports Linux subsystem, in my opinion, Windows may come out Windows – Linux Edition that

  • uses the UNIX filesystem hierarchy standard
  • supports commercial device drivers (like printers)
  • supports Linux container virtualisation
  • can run Windows applications natively (without WINE)
  • run X window customised with Windows theme
  • uses its own package manager with package repository
  • is cheaper price

I believe, there will be a group of users interested in it!

Dell Vostro 5459 review and setup


Due to the changes of the career, I invested on Dell Vostro 5459, after a long survey. I chose it because it is compatible to Linux. The compatibility to Linux meaning that, all the hardware devices are accessible by Linux. Besides that, it has the NVIDIA graphic card, which allows me to use GPGPU to do my research and study. Moreover, I can play high quality 3D graphics games.

Ubuntu

So, the laptop I bought was pre-installed with Ubuntu. And, I was impressed by the Ubuntu first boot video, which can be found here.

Partition and bootloader

It is new laptop, thus the hard disk partitioning table is using GPT format instead of MBR format. And the laptop uses UEFI boot system by default. It will be very convenient to have multiboot with several OSes.

In order to do partitioning, I used my favourite tool, SystemRescueCD. But I failed to run the X11 window, due to the very new NVIDIA graphic card. (I believe I can run the X11 now.)

Before partitioning and formatting the hard disk, I checked the xorg.conf from the existing Ubuntu, believed that it can help me to figure out how to start X11 window in SystemRescueCD. Then I discovered that /etc/X11/xorg.conf does not exist. This is a very important point.

Consequently, I used the command-line interface to re-partitioning the hard disk. Because I was going to install Windows and Arch Linux on it.

Windows

Though I prefer Linux, Ubuntu not my primary OS. So, I have to install the Arch Linux. Before installing Arch Linux, due to the luxurious hardware specification, I intended to install Windows 7. The laptop does not have USB2.0, but only USB3.0, and I didn’t want to install Windows 7 through external DVD-ROM, because I didn’t want to burn Windows 7 to a DVD. As a result, Windows 7 with USB3.0 cannot be installed. Looking for the solution, extra drivers are required. Thus, I gave up Windows 7 and tried Windows 8.1. (Sorry, Windows 8 and 10 are not my favourite.)

Great. Windows 8.1 is not bad after installation. I came back to Windows drivers later, since Windows is my secondary OS, for the purpose of… gaming.

Arch Linux

Installing Arch Linux needs some skills, and Internet connection is very important. So, I installed all the packages based on the old laptop, just following the powerful Arch Linux Wiki.

NVIDIA

NVIDIA GeForce 930M is very troublesome. After installing Arch Linux, to fully utilise my graphic card, I decided to use NVIDIA driver instead of Nouveau.

However, nvidia-xconfig generated xorg.conf file does not work. I failed to run the X11 window as in the SystemRescueCD.

As a result, I removed the NVIDIA related section in the xorg.conf according to the Arch Linux forum here. And the pre-installed Ubuntu does not have the xorg.conf as well. After removing the file, X11 window works fine.

After running the Arch Linux and configuring my preferences, I found that some of the screensavers (from xscreensaver) showed the error message,

Xlib: extension "GLX" missing on display ":0"

So, I knew that there is something wrong with my Xorg configuration and the NVIDIA.

Keep doing the trial and error, then I discovered something called bumblebee. Actually I am still very confused with this bumblebee, only know that it is related to NVIDA Optimus. And, I also don’t know what the hell is NVIDIA Optimus, only know that it is something wonderful.

After installing bumblebee, then the nvidia-libgl package is replaced by mesa-libgl. And the xscreensaver did not show the error message above anymore.

Since installed bumblebee, I supposed I can use Optimus with optirun command. Running

optirun glxgears -info

I got the new error,

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
...

Then, I thought may be my NVIDIA is too new, so I tried to install nvidia-beta. But it did not solve the problem as well.

As a result, I tried nvidia-dkms. Yeah! It works. “optirun” works fine now.

Windows 8.1

I love Dell, because the drivers are available online. I just download all the important drivers, graphic card, sound card, WiFi drivers, etc. Then I booted into Windows 8.1, and installed all the drivers. I just wonder, Arch Linux can use the WiFi device immediately during the installation, but Windows cannot? That means, if I have Windows and WiFi only, but does not have the driver, then how can I download the drivers?

After installed all the drivers, then I booted into Arch Linux, but failed. Because I failed to mount the Windows partition in Linux after installing the drivers. Then I found that, it is because of the Fast Startup feature in Windows 8. (Solution is here, look for the Fast Startup.) Because Fast Startup causes the partition “not clean”, so that Linux cannot mount it.

After disabling the Fast Startup, then everything works fine now.

Data transfer

Transferring vast amount of data between computers is very time consuming. I previously used an external hard disk. But transferring data from a 500G laptop to a 1T laptop, using an external hard disk is not applicable, since I don’t have extra empty hard disk.

At the end, I used the ethernet cable to transfer the data. (This is what I learnt from my student previously.) In Linux, I used the Network Manager to share the wired connection. Then directly connect two laptops with a single ethernet cable, and router is not required. Ethernet cable is faster than WiFi, and I can transfer whatever data I want from A to B or vice versa.

But still, I have to use the SSH to mount the target laptop.

This is a time consuming process.

Hibernation and resume issue

Now the only problem is resume from hibernation in Arch Linux. The resuming from hibernation works inconsistently. I have tried to install Linux LTS version, but it is worse because I cannot use Fn key after booting in Linux LTS.

I am still figuring out how to solve this problem.

Best ever programmer text editor: Emacs


I was using jEdit. And once willing to change to, so called modern text editor, Atom Text Editor. Then I did some comparisons among the text editors. At the end, now my primary text editor for coding is Emacs.

Emacs requires some time to learn and practise. But at the end, I love it too much. It is so powerful, no other text editor to compare with it. But the primary usage is for coding.

What are the advantages? It has various powerful addons (packages). It is highly customisable. It can work in command-line, that means you can use it over the SSH. (But normally I use Vim instead.) Like Vim, it can browse a directory. It can also perform diff and merge (but I use meld usually). It can work with gdb for debugging. It has syntax highlighting on different languages. It can perform different indentation based on various languages. Syntax highlighting can work on web development which combines JavaScript, CSS, HTML, and even PHP (using “web mode”). It can save the opened files as a project, so that you can work on multiple projects. It can split the views vertically and horizontally, basically unlimited splits. If you want, you can play Tetris in it. It can be used as window manager too.

There are several modes that are interesting. I suggest to know these modes:

  • dired – Directory browsing
  • ibuffer – List and manage opened files
  • eshell – Emacs shell, like bash
  • ielm – Inferior Emacs Lisp Mode. Interactive Lisp environment
  • w3m – w3m web browser, requires package installation.
  • eww – Default web browser in Emacs, but I found it is difficult to use compared to w3m

Customising Emacs to fit your pattern requires some time.

Just share my .emacs file,

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(buffers-menu-max-size 10)
 '(column-number-mode 1)
 '(ediff-split-window-function (quote split-window-horizontally))
 '(inhibit-startup-screen t)
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "DejaVu Sans Mono" :foundry "unknown" :slant normal :weight normal :height 113 :width normal)))))


;; Emacs default setting
(desktop-save-mode 1)
(global-linum-mode 1)
(savehist-mode 1)
(global-auto-revert-mode t)
(setq column-number-mode 1)
(delete-selection-mode 1)

(setq backup-inhibited t)
(setq auto-save-default nil)
(setq mouse-drag-copy-region nil)


(setq-default indent-tabs-mode nil) ;;Disable indent tabs globally
;;Create my own function
(defun my-toggle-tab ()
  (interactive)
  (if (default-value indent-tabs-mode)
      (progn
        (message "Space indent")
        (setq indent-tabs-mode nil)
        )
    (progn
      (message "Tab indent")
      (setq indent-tabs-mode t)
      )
    )
  )
(global-set-key (kbd "C-x C-t") 'my-toggle-tab)


;; Very annoying that override the content with delete word http://stackoverflow.com/questions/6133799/delete-a-word-without-adding-it-to-the-kill-ring-in-emacs
(defun backward-delete-word (arg)
  "Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
  (interactive "p")
  (delete-region (point) (progn (backward-word arg) (point))))
(global-set-key (kbd "<M-backspace>") 'backward-delete-word)



;; Change font for Chinese characters
(set-fontset-font t 'han (font-spec :family "WenQuanYi Zen Hei Mono"))



;; mouse from http://www.emacswiki.org/emacs/SmoothScrolling
(setq mouse-wheel-scroll-amount '(4 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time

;; Delete whitespace when save
(add-hook 'before-save-hook 'delete-trailing-whitespace)


;; White space mode
(global-whitespace-mode 1)
(autoload 'whitespace-global-mode "whitespace"
  "Toggle whitespace visualization." t
  (setq whitespace-style (quote (face spaces tabs space-mark tab-mark)))
  )
(autoload 'whitespace-toggle-options "whitespace"
  "Toggle load `whitespace-mode' options." t)


;; Add MELPA
(require 'package)
(add-to-list 'package-archives
	     '("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)


;;Recent file
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 15)
(global-set-key (kbd "C-x C-r") 'recentf-open-files)


;; Load undo-tree and set the undo/redo hotkey
(require 'undo-tree)
(global-undo-tree-mode 1)
(global-set-key (kbd "C-z") 'undo-tree-undo)
(global-set-key (kbd "C-S-z") 'undo-tree-redo)



;; Smooth scroll
(require 'smooth-scroll)
(smooth-scroll-mode 1)


;; Enable auto-complete
(require 'auto-complete)
(global-auto-complete-mode 1)


;; Enable hideshowvis to fold and expand the code
;;(require 'hideshowvis)
;;(hideshowvis-minor-mode 1)


;; Make web-mode to indent with 2 spaces, https://emacs.stackexchange.com/questions/2355/make-web-mode-always-indent-with-spaces
(require 'web-mode)
(defun my-web-mode-hook ()
  "Hooks for Web mode."
  (setq indent-tabs-mode nil)
  (setq tab-width 4)
  (setq web-mode-markup-indent-offset 2)
  (setq web-mode-css-indent-offset 2)
  (setq web-mode-code-indent-offset 2)
  (setq web-mode-style-padding 0)
  (setq web-mode-script-padding 0)
  (setq web-mode-enable-css-colorization t)
)
(add-hook 'web-mode-hook  'my-web-mode-hook)



;; Disable csharp-mode tab
(require 'csharp-mode)
(defun my-csharp-mode-fn ()
  "function that runs when csharp-mode is initialized for a buffer."
  (turn-on-auto-revert-mode)
  (setq indent-tabs-mode nil)
)
(add-hook  'csharp-mode-hook 'my-csharp-mode-fn t)


;;Auto js2-mode
(autoload 'js2-mode "js2-mode.el" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))


;;HTML
(autoload 'web-mode "web-mode.el" nil t)
(add-to-list 'auto-mode-alist '("\\.html$" . web-mode))
;; (add-to-list 'auto-mode-alist '("\\.php$" . web-mode))

(autoload 'pkgbuild-mode "pkgbuild-mode.el" "PKGBUILD mode." t)
(setq auto-mode-alist (append '(("/PKGBUILD$" . pkgbuild-mode)) auto-mode-alist))

(require 'w3m-load)
(setq w3m-default-display-inline-images t)


(require 'desktop+) ;;Use the desktop+

;; (autoload 'php-mode "php-mode.el" "Php mode." t)
;; (setq auto-mode-alist (append '(("/*.\.php[345]?$" . php-mode)) auto-mode-alist))
;; (autoload 'python-mode "python-mode.el" "Python mode." t)
;; (setq auto-mode-alist (append '(("/*.\.py$" . python-mode)) auto-mode-alist))

It would be better if you learn Emacs from the beginning and try to adapt the default key bindings (hotkeys). Because, if you replace some of the hotkeys with the ones you are used to, you may miss the default key binding power. No more Ctrl+X, C, or V for cut, copy, and paste. Just learn Emacs and customise it.

One more thing, I was looking for folding (collapse and expand) feature. But failed to find one. Yet, just use the key binding C-M-p and C-M-n are enough to fit my demand.

The following is the video which I screencasted with SimpleScreenRecorder and edited by Blender.

Xfce4, LXDE, and Openbox


What I need is performance, eye candy is optional.

My primary desktop environment is Xfce, as it is more lightweight than GNOME, KDE, or Cinnamon (Mate is out of my choice), yet it has more goodies (plugins) than LXDE. But due to my 4-year-old laptop, I found that LXDE has better performance than Xfce significantly. I can run multiple heavy applications at the same time, especially Firefox and Chromium. Xfce performance drops when I run both applications simultaneously. Switching between applications is slower. If running with Skype at the same time, and doing some development testing, the performance drops drastically.

LXDE is even more lightweight than Xfce. That is why I used LXDE. The only drawback of LXDE is that it does not allow me to zoom the screen with Alt+Mouse Scroll. This is a crucial feature I need as a lecturer. In order to gain a better speed, I also have to sacrifice the wallpaper auto changing as in Xfce. Furthermore, configuring the LXDE is a little troublesome. Since LXDE is using Openbox as window manager, a lot of configurations depend on the Openbox.

Openbox configuration

To configure the LXDE Openbox, we can use the obconf to configure. It is actually editing the ~/.config/openbox/lxde-rc.xml.

obconf also works on Openbox (window manager only). The corresponding file is ~/.config/openbox/rc.xml.

Hotkey configuration

LXDE hotkeys are depending on the Openbox too. We can use the obkey to configure the hotkeys. It is also editing the ~/.config/openbox/lxde-rc.xml or rc.xml.

Openbox right-click context menu

LXDE has its own panel (lxpanel). It allows to show (mostly) all the applications in the menu. However, if we right-click Openbox desktop area, the context menu does not show the installed applications. The application menu in the Openbox is actually written in the ~/.config/openbox/menu.xml. The skeleton file contains the hard coded applications.

There are several ways to show the menu items dynamically based on the installed applications. I personally use openbox-xdgmenu by adding something like this to the menu.xml,

<menu execute="openbox-xdgmenu /etc/xdg/menus/lxde-applications.menu" id="desktop-app-menu" label="Applications"/>

menu.xml is also used by Openbox without running the LXDE. That means, if a user login with Openbox window manager instead of LXDE, it will use the same menu.xml.

However, this can be changed by editing the lxde-rc.xml (LXDE) or rc.xml (Openbox window manager only) to load specific menu XML file. As a result, we are allowed to have different menu.xml files, one for LXDE and one for Openbox (window manager only).

Autostart

Autostart is quite complicated. If using LXDE, Xfce, or Openbox, the application desktop files in the ~/.config/autostart will be launched once login. They can also be disabled.

However, LXDE also allows autostart through ~/.config/lxsession/LXDE/autostart, where the LXDE is the default profile name. The autostart file is not exactly a shell script, but we can add the commands in this autostart file.

Though LXDE is based on Openbox, it does not use ~/.config/openbox/autostart file. If we login with Openbox window manager only, then ~/.config/openbox/autostart will be sourced (called) instead. This autostart file is just a shell script. As a result, we can use control structure like if-else. In order to run a batch of commands immediately, we can use the “&” to run the commands in the background.

There is another thing worth to know. If our display manager is LXDM or LightDM, it will source the ~/.xprofile. However, if we write our commands in the .xprofile, (I think) the commands will called before the DE is totally loaded. Therefore, the command like “compton” will not affect the Openbox. (Compton is an X window compositor, so that the Openbox will become compositing window manager.)

Openbox applications

Since Openbox is just a window manager, if we login with Openbox window manager only, there is no panel, wallpaper, volume control, etc. Therefore, we have to install the packages by our own. Besides that, Openbox does not handle graphical logout. However, we can install oblogout and add it to the Openbox menu.

I personally use the tint2 as the panel, feh for the wallpaper for both Openbox and LxDE (since I don’t use PCManFM), volumeicon for controlling the volume, compton to composite the window, and xscreensaver for screen saver. tint2 has the battery indicator and date time indicator. So, this is how my Openbox look.

Openbox with Tint2

Openbox with Tint2