Adding a gif-file as a screensaver to xscreensaver

•2013-08-01T12:35:02+00:00 • Leave a Comment

If you want to have a gif as a screensaver there are probably a lot of solutions. For example this

Man Bowl

loop as a screensaver could easily be created as a screensaver with xscreensaver and gifview [part of gifsicle (ArchLinux)]. In the ~/.xscreensaver file is a section with “programs:”, in that one you can add programs, which can write into the root window and understands “virtual root” windows.

Now that part of xscreensaver looks like:

textURL:        http://twitter.com/statuses/public_timeline.atom

programs:                                                                     \
-                               maze -root                                  \n\
- GL:                           superquadrics -root                         \n\
                                sh /path/to/script/screensaver.sh           \n\
-                               attraction -root                            \n\

The script looks like:

#!/bin/sh

GIF=/home/knorke/.screensaver/screensaver$XSCREENSAVER_WINDOW.gif
OLDGIFS=/home/knorke/.screensaver/screensaver*.gif
GIFFILES=(/home/knorke/.screensaver/images/*.gif)

rm $OLDGIFS
ln -sf "${GIFFILES[RANDOM % ${#GIFFILES[@]}]}" $GIF
gifview --animate --min-delay 5 --window $XSCREENSAVER_WINDOW $GIF

This will set a symbolic link to a specific file of a set of gif images for each display. We get a random gif for the display in the line which stats with ‘ln -sf’. But there is still a lot of improvement to do, e.g. displaying them centralized and not repeated and so on. The minimum delay in gifview gives the time of 1/100s between the display of each frame, this helped me with one gif, which was otherwise running too fast.

If you now open the configuration panel of xscreensaver with

# xscreensaver-demo

You should see in the small preview window of Sh the gif, which is mentioned in the configuration file. The preview button should show you, how it would be too see your endless loop in action.

sources:

man 1 gifview
man 1 xscreensaver
https://bbs.archlinux.org/viewtopic.php?id=73902
http://stackoverflow.com/questions/701505/best-way-to-choose-a-random-file-from-a-directory-in-a-shell-script

Resizing LVM-volumes with an ext4 filesystem

•2012-11-25T14:43:08+00:00 • Leave a Comment

If you have multiple partitions and one of them is full, you can shrink some of them and extend the one needed. First you need to reduce the filesystem and then reduce the partition. Be sure it is unmounted and do a filesystem check if everything is all right.

# unmount /dev/mapper/vg-disk1
# e2fsck -f /dev/mapper/vg-disk1
# resize2fs -p /dev/mapper/vg-disk1 100G
# lvreduce -L 100G /dev/mapper/vg-disk1

This reduces the size of the partition absolute to 100G. Now you repeat this steps with the other disk, you want to get some space of. If the e2fsck failed, you can extend the partition further up until it works with:

# lvextend +1G /dev/mapper/vg-disk1

Now you can extend the partition and resize the filesystem with:

# umount /dev/mapper/vg-disk0
# lvextend -l +100%FREE /dev/mapper/vg-disk0
# e2fsck -f /dev/mapper/vg-disk0
# resize2fs -p /dev/mapper/vg-disk0
# e2fsck -f /dev/mapper/vg-disk0

This will be it, you can mount the device and use it like before with more space. With the extensive use of e2fsck you can check, if everything worked right.

sources:

http://pubmem.wordpress.com/2010/09/16/how-to-resize-lvm-logical-volumes-with-ext4-as-filesystem/

Suspend for LXDE and SLiM

•2012-11-06T11:40:43+00:00 • Leave a Comment

After updating the computer, the login to the graphical interface was not able anymore. The terminal login still worked, after replacing lightdm with SLiM via:

# aptitude install slim
# aptitude dpkg-reconfigure slim

Now, you should be able to login via SLiM and not with lightdm. But a new problem arises, you cannot suspend anymore… After some testing, there was a command with which the computer could be suspended:

# /usr/sbin/pm-suspend

In SLiM you have to uncomment in the default configuration file (/etc/slim.conf) the suspend_cmd:

# suspend_cmd sudo /usr/sbin/pm-suspend

In this case the computer runs on ubuntu 12.04 and the suspend works with sudo pm-suspend for the normal user. But now there was still the problem, that the pc could not be suspend with normal user rights. This seems to be controlled by the dbus system. There are two storages for configuration files, which can give or deny permissions to user (/etc/polkit-1/localauthority/ and /var/lib/polkit-1/localauthority). /etc is for local configuration and /var is for third-party-applications. I put the file costum-actions.pkla into /etc/polkit-1/localauthority/50-local.d/:

# [Actions for computer user]
# Identity=unix-user:username
# Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*
# ResultAny=yes
# ResultInactive=yes
# ResultActive=yes

You can seperate more user with unix-user:userOne;unix-user:userTwo etc. for more information use the man page on pklocalauthority. After a reboot it worked, hopefully there are no flaws o:

sources:

http://wiki.ubuntuusers.de/Displaymanager
https://wiki.archlinux.org/index.php/SLiM#Shutdown.2C_reboot.2C_suspend.2C_exit.2C_launch_terminal_from_SLiM
http://wiki.xbmc.org/index.php?title=HOW-TO:Suspend_and_wake_in_Ubuntu

Postfix for smartd and mdadm

•2012-10-25T17:33:02+00:00 • 2 Comments

If you are using mdadm and smartd to monitor your hdd and raid, you probably want to be informed if they find any errors or so. So there is postfix which can send mails via sendmail to your e-mail address. It is quite useful to get one of a free webmail service. Would be better to encrypt them though.

First of all, you will need to install postfix (this one is for arch linux, the configuration is the same for ubuntu).

# pacman -S postfix

Now you need to edit the main.cf file, to configure postfix.

# sets gmail as relay
relayhost = [smtp.gmail.com]:587
# use tls
smtp_use_tls=yes
# use sasl when authenticating to foreign SMTP servers
smtp_sasl_auth_enable = yes
# path to password map file
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# list of CAs to trust when verifying server certificate
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
# eliminates default security options which are incompatible with gmail
smtp_sasl_security_options =

Next thing to do is to give your credentials in a postfix readable form. So write them into /etc/postfix/sasl_passwd:

[smtp.gmail.com]:587 username:password

With it gets into a .db file:

# postmap /etc/postfix/sasl_passwd

After a (re-)start of the postfix deamon:

# rc.d start postfix

you can check via:

# echo ‘hello world!’ | mail -s ‘first email’ username@gmail.com

if it worked.

After that bit is done, you can configure the other deamons to work with your e-mail address. For mdadm you have to add in your /etc/mdadm/mdadm.conf the

MAILADDR username@gmail

option. There can only be one. With

# mdadm –monitor –scan –test

You can check if the mail will be delivered. Now be sure that the demon runs on startup with your pc.

For smartd you need to modify the /etc/smartd.conf like:

DEVICESCAN -a -n standby,15,q -m address@domain.com -M test

If you (re-)start the daemon, you will get a test mail, so after it worked, just delete ‘-M test’ in the config. After -n are options to prevent the disks from idling for a test.

sources:

http://sherlock.heroku.com/blog/2012/02/03/setting-up-postfix-to-use-gmail-as-an-smtp-relay-host-in-archlinux/
http://www.novell.com/support/kb/doc.php?id=7001034
https://wiki.archlinux.org/index.php/S.M.A.R.T.#Email_potential_problems
http://sourceforge.net/apps/trac/smartmontools/wiki/Powermode

adding a brother multifunction device via cups/sane on arch

•2012-05-02T14:33:49+00:00 • Leave a Comment

To add a brother printer on an arch linux, you need the packages cups, ghostscript, gsfonts, foomatic-filters and arch x86_64 requires lib32-libcups. if you got cups installed, you need to add yourself to the cups admin group in /etc/cups/cupsd.conf. I added the group wheel:

SystemGroup sys root wheel

also you have to download the lpr and cupswrapper files from the brother driver page. if you take the .deb-files, you have to extract them via

# ar x *cupswrapper*.deb
# tar xfz *.gz

for both. or you can take the .rpm-files and use the package “rpmextract.sh” to extract these. then you need to change the location of cups in the cupswrapper script. cups is on arch in /etc/rc.d/cupsd not /etc/init.d/cups. now put the extracted files in your system, e.g.

# cp -r /path/to/extract/dir/usr/ /usr/
# cp -r /path/to/extract/dir/opt/ /opt/

now you can start the cupswrapper script as root. after cups was restarted, you can see on http://localhost:631 under “administration>manage printers” your printer. but it is installed for an usb connection. if you got network access, you need to modify the printer and use the option “other network printers>LPD/LPR Host or Printer”. there you need to write lpd:///BINARY_P1 , it did not worked with a dns name for me. in the next step press modify printer and try to print something.

to add the scanner, you need to install the brscan[1-4] package, which is suitable for your device via aur (makepkg -s, pacman -U *tar.xz). then execute (scanner model could be DCP-770CW)

# /usr/local/Brother/sane/setupSaneScan[1-4] -i
# brsaneconfig[1-4] -a name=SCANNERNAME model=SCANNERMODEL ip=IPADDRESS

You can test if your printer is now know via

# scanimage -L

sources

https://wiki.archlinux.org/index.php/Scanner_setup_%26_configure
https://wiki.archlinux.org/index.php/Brother_DCP-135C
https://wiki.archlinux.org/index.php/Brother_DCP-7020
https://wiki.archlinux.org/index.php/Brother_MFC-420CN
https://wiki.archlinux.de/title/Brother_Drucker

document converter with python and open/libreoffice

•2012-02-12T14:11:07+00:00 • Leave a Comment

docConvWP (it is actually .zip, you have to rename it, after you downloaded it) is a python script that converts .doc- into pdf files. optionally you can extract the images (the converter of libre/openoffice extracts them while converting a document into a web document.

you can call the script via:

# python start.py (doc-dir) (pdf-dir) [image-dir]

Then the script goes into every dir in doc-dir and puts all .doc-files as .pdf into the pdf-dir (plain, without the old folder-structure). I work with a script made by oooninja, which does the whole part of the converting. in order to start the converting process, you need to start open/libreoffice into some kind of server mode.

sources;

http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html

smb/rsync – cannot allocate memory

•2012-01-02T19:08:17+00:00 • 3 Comments

To sync a set of files from a linux raid to backup-HDD in a windows machine, you need to mount it (depending on your share, network, etc.) via:

# mount -t cifs /mnt/smb 192.168.1.2:’data’ -o username=bob

Now you could copy your files via:

# rsync -avP /home/user/datadir /mnt/smb/datadir

But after a while windows will not allow to copy any more data and rsync cannot allocate enough memory. This can be allowed via a few registry entries:

  1. Set “HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache” to “1″.
  2. Set “HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size” to “3″.
  3. Restart the “server” service.

Another problem you might run into is, that the vfat file system is not able to use question marks in file names. Unfortunately ext[2,3,4] can, so you are not able to copy the data. There is a patch for rsync which would transliterate the question marks with other characters, but it is just on the wish list and so you will have to patch it yourself or maybe wait until it is integrated in the next version. Also you could rename all the files with question marks in it or write a script which would do that.

sources:

http://jlcoady.net/windows/how-to-resolve-mount-error12-cannot-allocate-memory-windows-share
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570898

 
Follow

Get every new post delivered to your Inbox.