Showing posts with label X. Show all posts
Showing posts with label X. Show all posts

This Week I Learned - 2016 Week 27

Looking back to the last week post or you might want to check out the whole series.

What is Modern Perl? (via HN). The transition of Perl development motto from TMTOWTDI (pronounced Tim Toady) to TIMTOWTDIBSCINABTE (Tim Toady Bicarbonate). It took them (the Perl community) quite a long time to realize that consistency is not a bad things. Some approaches are really preferable but at least there should be a consistency way of coding, hence coding convention should and would exists in a project or a team.

REPL for Perl? Well, you will have to install Devel::REPL with some customization and workaround. To get started, just install these modules and run these commands.
# Prevent Data::Dump::Streamer failed to install error.
# See https://rt.cpan.org/Public/Bug/Display.html?id=100488
$ cpanm PadWalker 

# Enable command history
# See http://stackoverflow.com/a/28818133
$ cpanm Term::Readline::Gnu 

# Install the REPL
$ cpanm Devel::REPL

# Run the REPL
$ re.pl

# Find the Perl version through '$]' and '$^V' Perl's variables.
$ $]
5.024000

$ $^V
v5.24.0

# Quit from the REPL.
$ exit

How X11 works. Wonderful guide on underlying structure of X Windows System.

Free Perl programming books. Didn't realize there are still a lot of unknown, although quite old, Perl books.

Do you suffer from compulsive hoarding? Then r/datahoarder is for you. Be warned, you will burn some extra money to collect these data.

Probably the minimum Vim settings (compare to this and this) to have a good usage experiences, especially when administrating a server through the console.

How to write defensive Bash script. There is always one rule that I never follow, whic is to explicitly make all variables 'local'. Not a good habit if you want to be proficient at console.

It's the future. Be aware of over-engineered and complex solutions for your application before you decide to adopt it to your technology stack.

Awesome list of Perl resources. While we're at it, should you still use Perl?

It has been a while since I last follow with any CSS standard. For me, the existence of CSS frameworks means that the CSS is a solved issue for web development. One thing I noticed that the CSS box-model have changed these days till we have International box-sizing awareness day which the default 'box-sizing' should be 'border-box'. It seems that the Internet Explorer was rights about the default box calculation.

Buggy Nouveau Driver in Fedora 20

Regardless what GNU/Linux distros, I still faced the same issue regarding the Nouveau, the open-sourced driver Nvidia graphic cards.

While using the 3.16 kernel, I can't seemed to boot into the graphical login. Is all blank page. It was perfectly fine using the 3.11 kernel.
$ uname -sr
Linux 3.16.2-201.fc20.x86_64

In the end, I've to switch to the console login by Ctrl-Alt-F2, and checking the systemd journal log. Sample error message relating the Nouveau driver as shown.
$ journalctl -r | grep nouveau
Sep 27 11:23:24 butterfly kernel: nouveau E[   PFIFO][0000:01:00.0] CACHE_ERROR - ch 0 [DRM] subc 2 mthd 0x0130 data 0x0000000
......
Sep 27 10:16:43 butterfly kernel: nouveau E[     DRM] GPU lockup - switching to software fbcon

Some quick search revealed that to stop the X from freezing during startup, you've to disable Nouveau acceleration, which is the common, typical, and conventional solution. There are two ways.

First, adding 'nouveau.nofbaccel=1' to the kernel parameter. This can be done during Grub2 bootup by pressing 'e' and append, after the 'rhgb quiet' the option line to the kernel parameter. It looks something like below.
...rhgh quiet nouveau.nofbaccel=1

Later, just press F10 key to continue booting the system. However, you'll have to do this everything you boot up your machine.

Second, to make this a permanent solution, you'll need to modify the Grub2 configuration. Again, there are two ways to do so.

Edit the /etc/default/grub and append 'nouveau.nofbaccel=1' to the line GRUB_CMDLINE_LINUX and update the Grub2.
$ sudo grub2-mkconfig --output=/boot/grub2/grub.cfg

Another approach is the set the configuration through module configuration file when the kernel is loading. I prefer this option as it is easier to change than using the Grub2 way.
$ sudo sh -c 'echo "options nouveau nofbaccel=1' > /etc/modprobe.d/nouveau.conf "

You may ask, why not using the proprietary Nvidia driver? Well, unfortunately, I can't get it to work correctly, especially with latest 3.16 kernel. And, I don't want to waste my time on troubleshooting the same issue again and again.

Stuck with Nouveau driver forced me to switch my desktop environment from Gnome 3 to Xfce4. I've learned that without well-supported graphic card driver, Gnome 3 experience still a lot to be desired. Mind you, this workstation is running on 20GB ram and yet, it does not help.

While not as fancy as Gnome 3, Xfce4 seems acceptable for my daily usage compare to other desktop environment.

mkdtemp: private socket dir: Permission denied

Woke up this morning and my GDM login kept kicking me out of the login. Ctrl+Alt+F1 back to the console shell and check all the logs message. Based on the similar incident I've faced few months back, check the the .xsession-errors file. Result as shown.

Go to my home directory.
$ cd

Read the X's session log file for some clue.
$ cat .xsession-errors
/etc/gdm3/Xsession: Beginning session setup...
localuser:kianmeng being added to access control list
openConnection: connect: No such file or directory
cannot connect to brltty at :0
Script for scim started at run_im.
Script for auto started at run_im.
Script for default started at run_im.
mkdtemp: private socket dir: Permission denied

Googled around, it seemed that this is quite a common issue. To confirm my finding.
$ ls -ld /tmp
drwxr-xr-x 17 root root 20480 Jun 15 12:42 /tmp/

Applied the fix.
$ sudo chmod a+wt /tmp

What is the actual root cause? Last I remembered, I was restarting the machines repeatedly without login to the machine, for some BIOS settings tweaking. Most likely that's reason.

Multiple Monitors Support in GNU/Linux

For the past two months, I've been busy configuring multiple monitors support for different machines. Instead of tweaking X's configuration file, I've found a easier way to configure it using aRandR, a frontend tool to XRandR.

Install the packages
$ sudo apt-get install arandr

Run it and configure your monitors layout. You can easily drag-and-drop and position your monitors.
$ arandr

To make the XRandR changes permanent and run it everything the X session start. Save the settings generated by aRandR in your home folder as $HOME/.xprofile.

Lightdm Login Loop Issue in Ubuntu 13.10

Not sure what's going on but my lappy failed to log me in since yesterday. Symptoms of the issues are:
  • Loop back to login page even for correct password.
  • Guest login works.
  • No issue when switching to gdm.
$ sudo service stop lightdm
$ sudo dpkg-reconfigure lightdm
$ sudo start gdm

Surprisingly, this is quite a common problem as posted which I eventually traced the issue down to incorrect file permission for ~/.Xauthority file. Removing that file and login seems to work.
$ ls -l .Xauthority 
-rw------- 1 root root 57 Feb  25 01:05 .Xauthority

Someone did ask about this .Xauthority file and why file ownership was set to root? Best answer given which I quote here (emphasis added).
"The .Xauthority (not .xAuthority) file can be found in each user home directory and is used to store credentials in cookies used by xauth for authentication of X sessions. Once an X session is started, the cookie is used to authenticate connections to that specific display. You can find more info on X authentication and X authority in the xauth man pages (type man xauth in a terminal).

So, if you are not the owner of this file you can't login since you can't store your credentials there.

This situation usually arises when you execute a GUI application (for instance nautilus) with root permissions by typing sudo nautilus. You can avoid it (for 12.10 and older versions) by invoking the app with gksudo nautilus."

Which I suspect the root cause of this issue is that I always use sudo to start any graphical application where I shouldn't as described in RootSudo wiki entry as quoted below (emphasis added).
"You should never use normal sudo to start graphical applications as Root. You should use gksudo (kdesudo on Kubuntu) to run such programs. gksudo sets HOME=~root, and copies .Xauthority to a tmp directory. This prevents files in your home directory becoming owned by Root. (AFAICT, this is all that's special about the environment of the started process with gksudo vs. sudo)."
If that the case, then why gdm works but not lightdm?

Debian 7 Installation : Part 5 - Graphic Adapter (Nvidia)

Since I have an old legacy Nvidia graphic card that support dual monitors (VGA and DVI port), might as well reuse it again to setup my home development environment. This card will support two DELL E190S LCD monitors, the last of the remaining square size monitor still being manufactured.

Let's follow the wiki instruction to detect, install, and configure this graphic card to the maximum potential output. If you insert the card properly, the original Matrox adapter will be disable, otherwise you'll need to take it out again and reinsert it back.

First, let's find the exact model number. As shown below, the card is GeForce 7300 SE/7200 GS.
$ lspci - nn | grep VGA
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation G72 [GeForce 7300 SE/7200 GS] [10de:01d3] (rev a1)

Alternately, instead of using lspic command, we can use lshw command as well, which show more hardware details.,
$ sudo apt-get install lshw
$ sudo lshw -C display
  *-display               
       description: VGA compatible controller
       product: G72 [GeForce 7300 SE/7200 GS]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: [email protected]:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:16 memory:d2000000-d2ffffff memory:c0000000-cfffffff memory:d1000000-d1ffffff

Next, we need to detect the Graphic Processing Unit (GPU) to make a recommendation for the matching drivers to be used. I used to set it up on two LCD monitors few years back and driver support should be stable and good enough.
$ sudo apt-get install nvidia-detect
$ nvidia-detect 
Detected NVIDIA GPUs:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation G72 [GeForce 7300 SE/7200 GS] [10de:01d3] (rev a1)
Your card is supported by the default drivers and version 173.
It is recommended to install the
    nvidia-glx
    package.

Following the wiki instruction again, let's install the necessary packages for this graphic card. If you haven't add the non-free repository, type this command to add the non-free repository.
$ cat 'deb http://http.debian.net/debian/ wheezy main contrib non-free' \
| sudo tee /etc/apt/source.list.d/wheezy-non-free.list

Note that I don't modified the default repository list file (/etc/apt/sources.list) as it is easier to put every repository details in /etc/apt/source.list.d folder and rename it to something else if want to disable it. This is a matter of preferences.

Finally, we will update the update the package index files and install the necessary packages.
$ sudo aptitude update
$ sudo aptitude r install linux-headers$(uname r|sed 's,[^]*[^**]*-,,') nvidia-kernel-dkms

Again, we don't use the default /etc/X11/xorg.conf file anymore but instead put it as separate file in /etc/X11/xorg.conf.d folder. Is easy to toggle a configuration file using such mechanism. More on this later when we want to setup for dual monitors.
$ sudo mkdir /etc/X11/xorg.conf.d
$ echo -e 'Section "Device"\n\tIdentifier "My GPU"\n\tDriver "nvidia"\nEndSection' \
| sudo tee /etc/X11/xorg.conf.d/20-nvidia.conf

Lastly, before we reboot the machine, we need to install the GUI software to manage the graphic card settings. See the screenshot below.
$ sudo apt-get install nvidia-settings
$ sudo nvidia-settings
$ sudo reboot

Debian 7 Installation : Part 4 - Graphic Adapter (Matrox)

Checking the VGA display adapter used by the machine. Surprising to find the long forgotten graphic card manufacturer, Matrox on this machine.
$ lspci | grep -i VGA
01:00.0 VGA compatible controller: Matrox Graphics, Inc. MGA G200 AGP (rev 03)

Instead of using the default basic VESA driver which is quite slow (you can see the screen slowly refresh itself), we opt for the exact vendor driver instead.

Following the configuration instructions by pc-freak, we need to rebuild and install vendor driver for getting the best optimized performance from this legacy card.
$ sudo apt-get install --yes xserver-xorg-video-mga
$ sudo dpkg -i /usr/src/modules/mga-vid/debian/mga-vid-source_2.6.32-1_i386.deb
$ sudo apt-get install --yes mga-vid-common
$ sudo reboot