Hurray! Got my webcam working on linux

I was sitting at night browsing some friend’s blogs and adding RSS feeds to Akregator, after my new found fondness for KDE 4(more on that in a later post). Then Gaurish Sharma asked how to get webcam and fingerprint scanner to work on linux. I didn’t really have much clue but asked him to dig around with /var/log/dmesg and /var/log/messages to get more info on the webcam to start with. While he was looking around, I decided to dig up my own webcam from the closet.

I connected the webcam to the PC just to see a bunch of errors being spewed out by /var/log/messages. Then I installed gspcav1 kernel module and loaded it

pacman -S gspcav1

modprobe gspca

Still, no go. I still got errors on reconnecting the webcam. Then, I peeked around the Arch Linux wiki and found some other drivers that may be needed by device. Then ran

lsusb

It showed up a microdia webcam but still /var/log/messages spewed out errors. Then I went for verbose option of lsusb to see if there’s anything worthwhile.

Here’s the lsusb -v output for those interested

Still nothing. 😦

Then I decided to remove bluetooth from the other port and insert the webcam there. And voila! there it works. The webcam was detected, no errors this time and the required device was created.

Now, to test if it works or not. I tried kopete but alas! it doesn’t support all the webcams and mine is in one of those unsupported ones. I started looking at other apps which support more webcams. I started with cheese and ekiga but both looked to install evolution-data-server, why would I want that? Then I installed skype

pacman -S skype

Then add the user to video group and execute

chown :video /dev/video0

Now, logout and log back in for group settings to take effect. Then I ran skype.

Hurray! My webcam worked! Though the picture was hardly visible, I would place the blame on the webcam rather since it hasn’t been used in years now and it has always been throwing out grainy pictures since the beginning.

Advertisements

qingy – a desktop manager with a difference

What is qingy?

Here’s the quote from qingy developers Quote:
qingy is a replacement for getty. Written in C, it uses DirectFB to provide a fast, nice GUI without the overhead of the X Windows System. It allows the user to log in and start the session of his choice (text console, gnome, kde, wmaker, …).

Source :- http://qingy.sourceforge.net

Features:-

  • It works
  • It remembers last user who logged in, with focus on password
  • It also rememebers last session each user chose
  • Alternatively it remembers last session on a per-tty basis
  • Fully themable
  • A theme will look the same on all machines, independently of the resolution
  • You can select your favourite theme, or a random one every time
  • Both text and X sessions are supported
  • You can start more that one X session at once
  • You can even start X inside a console when X sessions are already running
  • PAM support
  • Support for screen savers
  • Auto log-in support
  • Session locking support
  • Session timeout, with lock or logout as available actions
  • tty specific options support
  • Customizable key bindings
  • Text mode support

I came across qingy while browsing gentoo-wiki

Here is the gentoo-wiki qingy guide

Experience of emoving mysql in debian/ubuntu forcefully

I had faced this instance where there ocurred problem with mysql configuration in debian. Something went wrong with the configuration and could not be traced out. We needed to fix it soon and reinstall was the easy option as there was no useful data.
But, the package couldn’t be removed because mysql is stopped before removing, Here, what was happening was that the init script would neither start or stop mysqld due to configuration error. Thus, the package couldn’t be removed as it failed to stop mysql.
So, thus I followed a hack’ish kind of a method to remove mysql.
First I killed mysqld by using top. Then I edited the file /var/lib/dpkg/mysql-server.prerm to remove the relevant section. So, now when I remove the package, the script won’t try to stop mysql-server.
Thus, I was cleanly able to remove the package without any problems.
Also, you get choice whether you want to keep your databases or remove them. Thus, is safe if you have important database.
Though, this method doesn’t have any bad side effects as far as I know, but still it would be better to sort out the configuration issues but here I had no other choice as it was important to remove it quickly and also there were no important configuration saved.

Finch – IM Client for command line

Finch is an IM and IRC client for command line. It supports all the protocols supported by pidgin. Like pidgin, it makes use of libpurple. So, all your account configured for pidgin can be used on finch too .
It has nifty shortcuts based on alt keys to navigate around. Making it quite simple to use for those people who are faster with keyboard than with mouse. . Some frequently used shortcuts are :-

  • Alt + q – quit
  • Alt + c – close window
  • Alt + n – next window
  • Alt + p – previous window
  • Alt + a – View available actions
  • Alt + w – list of windows
  • Alt + m – move window
  • Alt + r – resize window
  • F10 – Show menu for current window
  • Alt + tab – next URGENT window
  • Alt + Shift + tab – previous urgent window

Not so difficult to remember the shortcuts. No use of mouse required at all
Alas! Keybindings don’t work under screen so I can’t run it in screen session rest everything is perfect.

Start rtorrent using init scripts

Searching around the net I came across 2 articles which helped in writing the init script presented below.
There are 3 versions of the script – one for gentoo based distros one for debian based distros and one for Fedora, which is quite similar to debian one.
Requirements for running the scripts

  • rtorrent
  • screen
  • adequate knowledge to operate rtorrent and screen

Steps to get started

  • Copy the contents of the script for your distro to a file
  • Save it with the name indicated in the script
  • Make the file executable with following command

chmod +x /path/to/file

  • Add it to your default boot level as indicated in the comments
  • Change the TUSER value from username to your username
  • Optionally you can change rtorrent to some other bittorrent client depending on your preference. NOTE:- It should be a CLI bittorrent client

The gentoo version of the script

#!/sbin/runscript

# To add the script automatically at the startup execute the following command in the terminal
# eselect rc add rtorrent default

RTUSER=username
TORRENT=/usr/bin/rtorrent

opts=”start stop”

depend() {
#this daemon needs internet to function
need net.eth0
use logger
}

start() {
#display to user that what is being started
ebegin “Starting rtorrent”
#start the process and record record it’s pid
start-stop-daemon –start –background –pidfile /var/run/rtorrent.pid –make-pidfile –exec su -c “/usr/bin/screen -dmUS torrent $TORRENT” $RTUSER
# To interact with rtorrent you will need to reattach the screen
einfo “To use your rtorrent session, reattach screen using following command:”
einfo “screen -r torrent”
#output failure or success
if [[ $? -eq 0 ]]; then
if [[ $? -eq 0 ]]; then
eend “Process started successfully”
else
eend “Process failed to start”
}

stop () {
#display that we are stopping the process
ebegin “Stopping rtorrent”
#stop the process using pid from start()
start-stop-daemon –stop –pidfile /var/run/rtorrent.pid –name rtorrent
#output success or failure
if [[ $? -eq 0 ]]; then
eend “Process stopped successfully”
else
eend “Process failed to stop”
}

Debian version

#!/bin/bash

# To start the script automatically at bootup type the following command
# update-rc.d torrent defaults 99

RTUSER=username
TORRENT=/usr/bin/rtorrent

case $1 in
start)
#display to user that what is being started
echo “Starting rtorrent”
#start the process and record record it’s pid
start-stop-daemon –start –background –pidfile /var/run/rtorrent.pid –make-pidfile –exec su -c “/usr/bin/screen -dmUS torrent $TORRENT” $RTUSER
#output failure or success
#info on how to interact with the torrent
echo “To interact with the torrent client, you will need to reattach the screen session with following command”
echo “screen -r torrent”
if [[ $? -eq 0 ]]; then
echo “The process started successfully”
else
echo “The process failed to start”
;;

stop)
#display that we are stopping the process
echo “Stopping rtorrent”
#stop the process using pid from start()
start-stop-daemon –stop –pidfile /var/run/rtorrent.pid –name rtorrent
#output success or failure
if [[ $? -eq 0 ]]; then
echo “The process stopped successfully”
else
echo “The process failed to stop”
;;

*)
# show the options
echo “Usage: {start|stop}”
;;
esac

Seems that debian version will work for Fedora too. Still, here’s the script

#!/bin/bash

# To start the script automatically at bootup type the following command
# chkconfig add torrent

RTUSER=username
TORRENT=/usr/bin/rtorrent

case $1 in
start)
#display to user that what is being started
echo “Starting rtorrent”
#start the process and record record it’s pid
start-stop-daemon –start –background –pidfile /var/run/rtorrent.pid –make-pidfile –exec su -c “/usr/bin/screen -dmUS torrent $TORRENT” $RTUSER
#output failure or success
#info on how to interact with the torrent
echo “To interact with the torrent client, you will need to reattach the screen session with following command”
echo “screen -r torrent”
if [[ $? -eq 0 ]]; then
echo “The process started successfully”
else
echo “The process failed to start”
;;

stop)
#display that we are stopping the process
echo “Stopping rtorrent”
#stop the process using pid from start()
start-stop-daemon –stop –pidfile /var/run/rtorrent.pid –name rtorrent
#output success or failure
if [[ $? -eq 0 ]]; then
echo “The process stopped successfully”
else
echo “The process failed to stop”
;;

*)
# show the options
echo “Usage: {start|stop}”
;;
esac

One thing I need to implement is to show status. If it is started or stopped. Reload or restart doesn’t seem to make much sense to me thus I haven’t implemented those.
This is only the initial version it may have bugs. Please report them so they can be corrected.
Debian and fedora users please try it and report if it works.
For user of other distros, if interested, please provide some idea of your distro’s init system or attach some init script so that I can work on it.
For people familiar with init system, it would be great to post your modifications/improvements/bug fixes/ideas to this script.

Mirage – A lightweight GTK+ Image Viewer

Being a fluxbox user I have been looking for some lightweight imageviewer. xloadimage can always be invoked from CLI whenever needed.
While helping a friend build up a XFCE based gentoo system we discovered mirage. Mirage needs only pyGTK installed, which should be available on most linux distributions these days.
Some of the useful features of mirage are :-

  • Lightweight
  • Easy to use interface
  • Small app coded in python and GTK+
  • Supports various image formats like png, svg, jpeg, gif, etc.
  • Shows thumnails of all images in current directory
  • Displays basic information about size, resolution and compression of images in the status bar at the bottom
  • Supports basic editing features like rotate, flip, crop, resize, saturation,
  • It can also show images in the current directory as a slide show.
  • Option for viewing remote images
  • It can also take screenshots and save it in png format

Here’s a screenshot of mirage taken in mirage itself

Mirage image from Mirage

Mirage image from Mirage

More can be found on Mirage’s website
It has 4 modes for opening a file –

  • Smart Mode,
  • Zoom to Fit Mode,
  • 1:1 Fit Mode and
  • Last Active Mode.

Here’s the definition of smart mode, from mirage’s website

Smart Mode uses 1:1 zooming if the image is smaller than the available space and Fit Mode if the image is larger.

It also supports command line arguments, though they may not be utilized too much. Nonetheless it is available if needed.

Now, I have left it’s best part to the last. It supports custom actions eg. pressing ctrl +e opens the image in gimp, alt + t to create thumbnail of the image and so on. All these can be easily changed too by editing it’s values in Edit=> Custom Actions=> Configure. You can also add new values as to your liking

One great use of mirage I have found for myself is when using elinks for browsing certain websites which are supposed to be text based but I may stumble upon a couple of interesting sounding images. Mirage can then be easily invoked from elinks to view the images from the website.