Thursday, February 28, 2013

CAMP - Console Ansi Mpeg3 Player


PLEASE NOTE: An official update of CAMP as of April 20 2013 is available here.



CAMP 1.5.3489 Console ANSI Mpeg3 Player (Rawlock skin).

Years ago I came across a really nice front end for mpg123 called CAMP by Sector7's inm. I fell in love with it at first sight. Why, well because I love ANSI art! So recently when I started drifting towards creating a console only GNU/Linux system I had this little gem in the back of my head.


CAMP File selector (Rawlock skin).

CAMP Description editor (Rawlock skin).

CAMP Forked to background.


 I had to think hard (google) to actually remember the name of the app but luckily enough the website was (and is) still alive. Sadly the last update was in 2002. But hey! Maybe it didn't need more coding?

Or did it? Compilation gave me heaps of errors. Errors I first regarded as something way above my level of competence. Here's a few lines:

fork.c:120: error: too few arguments to function ‘exit’

fork.c: In function ‘stealback’:
fork.c:137: warning: incompatible implicit declaration of built-in function ‘exit’
fork.c:137: error: too few arguments to function ‘exit’
fork.c:146: warning: incompatible implicit declaration of built-in function ‘exit’
fork.c:150: warning: incompatible implicit declaration of built-in function ‘exit’
fork.c:188: warning: incompatible implicit declaration of built-in function ‘exit’
fork.c:188: error: too few arguments to function ‘exit’


I started out by mailing the author but as of now I've still haven't heard from him or her. Then again I'm not really expecting someone to jump at troubleshooting their eleven year old code as soon as random idiot from the internet e-mails them about it. So I turned my questions to the mighty google instead.

I quickly learned that the errors were quite easily remedied:
error: too few arguments to function ‘exit’
All the instances of exit() in fork.c needed to be replaced with exit(0).

warning: incompatible implicit declaration of built-in function ‘exit’
Add #include <stdlib.h> to the top of fork.c

After this the code will compile but still generates heaps of warnings. I've compiled a list of errors and remedies if you want a warning free compile, or you could just download my pre-fixed package further down.

How to download, make and install CAMP:

0 Install the dependencies
$ sudo apt-get install zlib1g-dev mpg123
Note: First time I tried to compile CAMP on my Debian box I never had any issues with dependencies. Well except mpg123 since that is what CAMP is a front end for. If you do find any missing deps please comment and I'll add them to the list above. 

1a. Get the latest code :
$ wget -c http://sector7.nu/camp/camp-1.5.3589.tar.gz

PLEASE NOTE:  An official update of CAMP as of April 20 2013 is now available. 
$ wget -c http://www.sector7.nu/camp/camp-1.6.3744.tgz

1b. Alternatively download my updated code that works for me.
$ wget -c https://www.dropbox.com/s/510hdr4g3mutb5p/camp-1.5.3589_makkan.tar.gz

2. Unpack the downloaded file.
$ tar xvzf camp-1.5.3589.tar.gz

3. Configure CAMP
$ ./configure

4. Compile and install CAMP
$ ./make && sudo make install

5. Install the skins
$ ./make install-skins 
Note: This installs the skins in ~/.camp/skins but for some reason the individual skin dirs are not executable i.e not possible to cd into. But it can easily be fixed by issuing:
$ chmod ug+x *  
in HOME/.camp/skins/

6. Configure CAMP, start by copying camp.ini from the source code directory to your home .camp/ dir
$ cp camp.ini ~/.camp/camprc
Then edit the camprc according to your preferences e.g location of mpg123, audio output etc.

7. run CAMP!
$ camp

Hey! Why does everything look like crap in Virtual console?


CAMP in console with $TERM Linux and locale sv_SE.ISO-8859-15
CAMP in console with $TERM Linux and locale sv_SE.ISO-8859-15

CAMP in console with $TERM Linux and locale sv_SE.UTF-8
CAMP in console with $TERM Linux and locale sv_SE.UTF-8

Well I've found a way to temporarily remedy this. Although I'm still researching better solutions. The one I have right now is to use one of the following settings: 
$ charset G0 cp437
$ charset G1 cp437

If for some reason your console turns out unreadable you can always go back with. Se more in the charset manpages.
$ charset G0 iso01
$ charset G1 iso01



CAMP in console with $TERM Linux, locale sv_SE.UTF-8 and charset cp437
CAMP in console with $TERM Linux, locale sv_SE.UTF-8
and charset cp437

Hey! Why does everything look like crap in PuTTY?


This one's easy. Just set the remote character set to the ISO-8859-X that suits you or type in CP850. It's under Window>Translation

Hey! Why does everything look like crap in PuTTY when I use GNU screen?


This one's easy. Just set the remote character set to the ISO-8859-X that suits you or type in CP850. It's under Window>Translation
And do the following:

set $LANG to C
$ export LANG=C

In screen set c1 to off: 
Press crtl+a+: and type c1 off 

and set UTF8 to off: 
Press crtl+a+: and type utf8 off off

Found these GNU Screen tricks in the amnesia/epic documentation here


Hey! Why does everything look like crap in xterm?


Don't know haven't had this problem yet. Hint might be to try something of the above.


Short description of warnings and remedies when trying to compile CAMP: 

warning: incompatible implicit declaration of built-in function ‘strcpy’

warning: incompatible implicit declaration of built-in function ‘strlen’

warning: incompatible implicit declaration of built-in function ‘strncat’

warning: incompatible implicit declaration of built-in function ‘strchr’
Add #include <string.h> to the top of the offending file.


warning: incompatible implicit declaration of built-in function ‘exit’
Add #include <stdlib.h> to the top of the offending file.

warning: incompatible implicit declaration of built-in function ‘printf’
Add #include <stdio.h> to the top of the offending file.


Wednesday, February 27, 2013

Reducing disk writes by putting /var/log in RAM (tmpfs)

**UPDATED 2013-03-01

I've recently grown quite fond of my old Toshiba Satellite* that currently exists in the form of a digital picture frame. I'm still not sure what to do with it but I've started exploring the possibilities of removing xorg completely and focusing solely on a command line interface.

First thing is that I want to make it more robust, i.e. protect the CF-card from excessive disk writes and possible power failure. I could go with a dedicated dist such as Slitaz, Puppy or Tiny Core but I kind of like my own debian system. So I decided to go with reducing disk writes.

I've taken a few steps to reduce disk writes already. But then there is the never ending logging. So I took some of my precious RAM and put /var/log in it. I found some instructions on that here.

To accomplish this I added the following line in /etc/fstab
tmpfs  /var/log  tmpfs  size=4M,defaults,noatime,mode=0755  0  0

So far I'm only using 4 MB but I could probably lower this. I just need to keep it running for a while and see how logrotate works.

To prevent the 4 MB of log space to fill up uncontrollably I've configured logrotate from the default weekly rotation of logs to daily rotation and keeping only 1 day of backlog. I also added a size limit to each log file to 100k. But as far as "man logrotate" tells me this won't affect the logs more than once daily as the logrotate cron job only runs once each day.

As of now I've edited /etc/logrotate.conf accordingly.

# rotate log files daily

daily

# keep 2 days worth of backlogs
rotate 2


**PLEASE NOTE!

The above had little effect on my running system. Turns out many of the logs had separate instructions in:/etc/logrotate.d
Update them accordingly and you should be in business.


* Toshiba Satellite 320CDS
CPU: 233 Mhz Pentium MMX
RAM: 96 MB
HDD: SandDisk Compact Flash 8 GB Extreme IV via Lycom CF 2 IDE Bridge
OS: Debian Gnu/Linux Squeeze

What time is it?

For some reason I can't use PTT Twitter anymore so I started to look around for another console based twitter client. I found TTYtter. However I ran in to problems with the time being way off on my Digital Picture Frame. Probably because I haven't bothered to set it at all.


http://www.linuxselfhelp.com/quick/clock.html
http://wiki-old.unix.se/NTP.html

http://wiki-old.unix.se/Cron.html