Thursday, January 20, 2011

Learn Vim

Just discovered that there is a great vim tutor on my machine; just type in terminal vimtutor.
I think it won't be my thing but it is nice to know the basics to be able to edit texts files one any pc.

These basics you learn in vimtutor and more, by doing not memorizing.

NOTE: Remember that you should be learning by doing, not memorization.

:q! quit vim withhout changing
:wq saving edited text, also ZZ


editing text -insert: i brings the insert mode; Esc to stop insert.
The letter position after the cursor highlighted letter is inserted
editing text append: Capital A moves the inserted text to end of line.
p put line below this line (moving lines)
ctrl+o opens new line below the present one: ctrl+O above.

stop editing text Esc
u undo last edit; U undo all editing on line
Ctrl+r redo command

moving cursor: h j k l cursor left down up right
motion: w- until the start of the next word, EXCLUDING its first character.
e - to the end of the current word, INCLUDING the last character.
$ - to the end of the line, INCLUDING the last character.
0 move to begin of the line
2w two words forward first letter
2e two words forward last letter

moving in text: Ctr+G is show on what line you are in text
G move to end of text; gg move to start of text;486G move to line 486
ctrl+o go back to last position
ctrl+i go forward again
ctrl+l moving cursor left while in insert mode
% find matching parenthesis

search forward: /searchword
search backwards: ?searchword
n search again; N search again other direction


delete letter: x cursor on letter is delete
delete word: dw delete word
delete line: dd
delete motions:
dw - until the start of the next word, EXCLUDING its first character.
de - to the end of the current word, INCLUDING the last character.
d$ - to the end of the line, INCLUDING the last character.

replace letter: rx to replace the character at the cursor with x: Capital R to replace more than one character, stopped by Esc.
replace word: ce deletes word and activates insert mode (ce- change till end word; remember motion operators)
replace line: c$

v visual mode being able to select text
y yank+copy text to buffer yw yank word
p paste selected text

:w write file

Substitute
s one character; S rest of line

To substitute new for the first old in a line type :s/old/new
To substitute new for all 'old's on a line type :s/old/new/g
To substitute phrases between two line #'s type :#,#s/old/new/g
To substitute all occurrences in the file type :%s/old/new/g
To ask for confirmation each time add 'c' :%s/old/new/gc

" Auto-completing words
In insert mode, type the beginning characters of a word that has appeared in
the file before.
Ctrl-N " auto-complete with next match
Ctrl-P " auto-complete with prev match



Nice links, reference card and book:
Vim is a beautiful tool - Eric Wendelin's Blog
Gentoo Wiki Archives - Vim

Reference Card Another one both PDF's

Vim Tutorial Book by Molenaar


Managing groups

Started using dbus for opening different partitions on hard drive.
Suddenly had an issue with refused rights.
Had to add myself as user to the group dbus: sudo gpasswd -a paul dbus

Clear Arch-wiki section about managing groups:

List groups

Display group membership with the groups command:

$ groups [user]

If user is omitted, the current user's group names are displayed.

To list all groups on the system:

$ cat /etc/group

Manage group membership

Add users to a group with the gpasswd command:

# gpasswd -a [user] [group]

To remove users from a group:

# gpasswd -d [user] [group]

If the user is currently logged in, he/she must log out and in again for the change to have effect.

source: https://wiki.archlinux.org/index.php/GroupsLink

Tuesday, January 18, 2011

Mplayer-vdpau-svn error when updating

The build I had made with packer of mplayer-vdpau-svn was outdated because of an update of /usr/lib/libx264.so.107 to /usr/lib/libx264.so.112.
I had to recompile it. packer -S mplayer-vdpau-svn
Found the error doing:
 ls -l /usr/lib/libx2*

So to update
packer -S
mplayer-vdpau-svn

It will give as feedback reinstalling but build again.

When you don't manage to start X

Or your screen resolution won't get right.

Many questions on the Archbang forum are related to issues with video drivers and failing screen resolution. People get stuck at a terminal or have a crappy screen display. This post is related to Arch using Openbox window manager.

Don't despair. If you managed to get a good screen resolution when testing with the live CD, then it also must be possible to achieve this after install. To put it in another way: always test with a live CD if this configuration on this live CD is working for your hardware.

Important is to see that the problems most of the time have a few different sources.

Editing grub

To begin with the beginning: sometimes grub is set to vesa to make login possible.
Don't expect the system to use the best driver for you videocard in that case.

To edit the grub boot menu you can press the e key and edit the line that has vesa in it and comment that out or with the terminal #nano /boot/grub/grub.cfg and delete XORG-VESA & NOMODESET.

This is for grub2; in grub legacy, 0.97, you can edit the /boot/grub/menu.lst

Also delete here the vesa and nomodeset options.

In Nano you use Ctrl+ o to write something, then enter and ctrl+x to close nano.

Installing the necessary video driver

If you don't know what hardware video device you have:
lspci -vnn gives a list of your hardware devices, which gives valuable info on which what hardware we are dealing with.
lspci -k gives info on how the kernel drivers handle your hardware at the moment; this is of course very important info too.

Another important source of info is:
On issues with xorg the log file /var/log/Xorg.0.log is often given to help others give support. This gives valuable feedback.
If you can't get into a terminal, use a live CD.
If you want to install a new driver you have to work from your installation on your hard drive.
Most of the time Alt+Ctrl+F2 will give you another working terminal, if you didn't managed to start X and got stuck.

How to install a new videodriver

with a Nvidia video card: sudo pacman -S nvidia nvidia-utils
with the ATi card : sudo pacman -S xf86-video-ati
Intel: sudo pacman -S xf86-video-intel

See also https://wiki.archlinux.org/index.php/Beginners%27_Guide#Install_video_driver


Now the third source of the problem or third kind of problem has to be checked or solved: your xorg.conf in /ect/X11/
With a normal effective install this won't be necessary, but accidents can happen
So nano /etc/X11/xorg.conf ; notice X11 is written with a capital X.

Before editing a xorg file always back it up!! Save it as xorg_old or xorg_default for instance.

Two kinds of problems are possible
1, the wrong driver is mentioned
2. the desired screen resolution(s) is (are) not given in xorg.conf

At problem 1: find vesa in the device section and replace it with nvidia or what your your videocard is called. Specify if possible the card type you are using.
My device section looks like this:

Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce GT 330"
EndSection

Edit: due to conflicts between xorg-server 1.11 and nvidia driver it may be necessary or more useful to install the nouveau driver:
So nvidia card using open source driver:
#pacman -S xf86-video-nouveau
and in in /etc/X11/xorg.conf.d/20-gpudriver.conf
instead of nvidia: nouveau

Problem 2: Screen resolution
Normally a screen resolution has not to be identified in the screen section of the xorg file
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "TwinView" "0"
Option "metamodes" "nvidia-auto-select +0+0"
SubSection "Display"
Depth 24
EndSubSection

when the correct driver is working,


but sometimes it has to.

It could look like something like this:

Section "Monitor"
DisplaySize 344 193
HorizSync 30-40
Identifier "Monitor[0]"
ModelName "Unknown"
Option "DPMS"
Option "PreferredMode" "1366x768"
VendorName "Unknown"
VertRefresh 50-75
UseModes "Modes[0]"
EndSection

BTW also font configuration issues can have a devastating effect on xorg and make X not working, crashing. See this post.


If you have finished working on your configuration you can reboot or do startx to start X.

Friday, January 14, 2011

Autocomplete or wordprediction in Linux

I looked for an word prediction feature in a simple text editor and found one for gedit.

At https://github.com/nagaozen/gedit-plugin-autocomplete/ you can find one.
Install script is in the download; make install file executable.
After the install go to Preferences, plugins, check the autocomplete plugin, select it and go to configure and add a wordlist (each lines, one word) to the open text pane.
For more elaborate snippet-like TextMate like code prediction, useful for programmers look at gmate-git.
Another option is (not tested) http://code.google.com/p/gedit-tm-autocomplete/.

Friday, January 7, 2011

roll back kernel version

For the first time I had kernel panic in Arch on old pc that seems to have some hardware issues; I could login on the fallback kernel - recovery mode, but then network wasn't working.

Found this info on kernel panic:

Roll back to previous kernel version

If you keep your downloaded pacman packages, you now can easily roll back. If you didn't keep them, you have to find a way to get a previous kernel version on your system now.

Let's suppose you kept the previous versions. We will now install the last working one.

First you need to get the kernel details.

# cd /var/cache/pacman/pkg
# find kernel*

Now use the kernel details in the command below. Link

# pacman -U /var/cache/pacman/pkg/kernel26-2.6.23.xx-x.pkg.tar.gz


More info here:https://wiki.archlinux.org/index.php/Kernel_panic

Wednesday, January 5, 2011

AdComps adapted Oblogout script

I use an adapted version of oblogout made by AdComp.
The special feature is that the shutdown button is automatically selected and you don't have to focus it with your mouse; so you can close your system blind.
Code here ; save in texteditor, make executable and put in folder oblogout in usr/share and adapt shortcut in rc.xml

Put these images in folder img in folder oblogout:
with following names in order:

system-shutdown.png



system-restart.png


system-log-out.png


application-exit.png


This last most left button means close oblogout, so is in fact a cancel button.

Create a symbolic link to /usr/bin:
[paul@archbang ~]$ sudo ln -s /usr/share/oblgout/oblogout /usr/bin/oblogout

Blog Archive