yet another random wallpaper script

8 05 2010

Yea, everyone has a random wallpaper script. I especially like the ones where the guys sift through a couple of text files to get a wallpaper selected. I’m always a big fan of doing more work than is needed. Do I really need to use sarcasm tags for you guys???
Well anyways, this script uses ls | sort- R | head -1 to get a random image at logon. That’s right guys, you don’t have to muck around with any random command I use feh to set the image also. You could easily modify this script for swapping out walls at an interval and to use your preferred wallpaper setter.
Well, here is my incarnation.
————-
#!/bin/bash
## Description: Sets a random wallpaper from a list generated by ls in the wallpaper directory. Uses feh to set wallpaper.

wall_dir=”/home/m4x/Pictures/walls/”
random_wall=`ls $wall_dir | sort -R | head -1`
/usr/bin/feh –bg-scale $wall_dir$random_wall
# end of script

And one modified to swap walls every 30 minutes and use a text file.
————-
#!/bin/bash
## Description: Sets a random wallpaper from a list generated by ls in the wallpaper directory. Uses feh to set wallpaper. Changes every 30 minutes.

wall_dir=”/home/m4x/Pictures/walls/”
wall_list=”walls”
while :;do
random_wall=`cat $wall_dir$wall_list | sort -R | head -1`
/usr/bin/feh –bg-scale $wall_dir$random_wall
sleep 30m
done
# end of script

How do I use these??
Well, just add it to your user’s startup script or make a desktop file in ~/.config/autostart .





various command line snippets

6 05 2010

Linux is fun. I love using the commandline, so every now and then when I come up with a command that I use more than once or it just took forever to figure it out I toss it in a file for future reference. They could be simple, short snippets or long piped out commands. Well they might not be perfect but they have served their purpose, so maybe some one else can use them.

# recursively make everything r/w
chmod -R 0777 *

# start a http server using python accessible at http://localhost:8000
python -m SimpleHTTPServer

# find playlist and ls in m3u text file
find . -iname ‘*.m3u’ -print0 | xargs -0 ls >> m3u

# find all playlist and delete
find . -iname ‘*.m3u’ -print0 | xargs -0 rm

# strip ID3v1 tags
find -name \*.mp3 -type f -print0 | xargs -0 id3v2 -s

# ls hidden files
ls -a | grep -v ^d | grep [.][a-zA-Z0-9] | cut -d. -f2

# find all albumart jpgs and rename to folder.jpg
IFS=$’\t\n’; for i in $( find . -iname ‘*.jpg’ ); do echo “Renaming” $i; mv $i ${i%/*}/folder.jpg; done

# lsmod but just the names no depends
lsmod | cut -c1-22

# join all avi in a directory
mencoder *.avi -o out.avi -ovc copy -oac copy

# mount a squashfs
mount filesystem.squashfs somefolder -t squashfs -o loop

# convert video to smv for my Philips GoGear 4GB, requires smv_encode, google it
smv_encode -g 220×176 -f 24 -n 5 -r -1 -q 60 “some_ffmpeg_supported_video” “some_video.smv”

# open links in thunderbird in firefox
gconftool-2 -s /desktop/gnome/url-handlers/http/command ‘/usr/bin/firefox %s’ –type String
gconftool-2 -s /desktop/gnome/url-handlers/https/command ‘/usr/bin/firefox %s’ –type String





sort wallpaper by dimensions

5 05 2010

Let’s say you have one large folder of wallpaper/backdrops and your tired of picking the wrong one because its dimensions are wrong for your screen. Well this script is one you might enjoy.

———————–
#!/bin/bash

## Description:let’s sort images/wallpaper into folders based on dimensions
##Depends: imagemagick

for i in $( find . -iname ‘*.jpg’ )
do
dim=`identify -format %w_x_%h $i`;
mkdir -p sorted/$dim
mv $i sorted/$dim
done





batch re-encode mp3s using lame

5 05 2010

Being a frugal type of guy, I purchased an mp3 player that only holds 4GB(really just 3.7GB of music). Well a large portion of my mp3s are encoded at 192kbps or higher so I really fit that many on it. Solution was simple, re-encode them down to 128kbps or lower using lame and id3lib. Most distros have them. Some scripts I looked at take all the bitrate info and write it to a text file then compare it to find out if it needs to be re-encoded, I really don’t think that is necessary to accomplish the task.

In this script I use file and pipe it through cut a few times to come up with my bitrate. This works pretty well unless you have a corrupt mp3. Well guess what, if it is too corrupt lame isn’t going to process it anyways. Sorry Charlie.

I use id3info(found in id3lib package) to get the existing ID3 tags. My mp3 player only supports artist, album and song title tags, so that’s what I use. If yours supports more by all means go ahead and check the man pages for lame and id3info for all that they have support for.

———————-

#!/bin/bash

## Description: Let’s batch reencode any mp3s that’s bitrate is higher than 128 for our mp3 player.
## Depends: lame -
## id3lib -

IFS=$’\t\n’

reset

for i in $(find . -iname ‘*.mp3′)
do

bit=$(file “$i” | cut -d”:” -f3 | cut -d”,” -f4 | cut -c1-4)
title=$(id3info “$i” | grep TIT2 | cut -d”:” -f2)
artist=$(id3info “$i” | grep TPE1 | cut -d”:” -f2)
album=$(id3info “$i” | grep TALB | cut -d”:” -f2)
target_bit=” 129″
out=temp.mp3

if [ "$bit" -gt "$target_bit" ]; then
echo “$bit $i ” >> reencode # prints a list of what was re-encoded. Can be commented out
nice -n 19 lame –cbr -b 128 –id3v2-only –tt $title –ta $artist –tl $album “$i” “$out”
mv “$out” “$i”
else
echo “$bit $i ” >> untouched # prints a list of what wasn’t re-encoded. Can be commented out along with above line.
fi

done





Let’s redo our mp3 ID3v2 Tags recursively

5 05 2010

So you have a bunch of mp3s that you want/need to tag/re-tag. You could use some of the fancy GUI programs out there. Kid3 and Easytag are just two that come to mind. Unfortunately you’ll have to input/type quite a bit if you have a lot of mp3s. So why not have your computer do it for you? So using some standard commands and a couple of packages most distros might have in their repositories we can accomplish it rather easily.
While this script will only tag your mp3s based on its file path it is not that hard to modify. Using a clever combination of file, cut, awk and sed you can add all the tags id3tag(part of the id3lib package) handles: artist, album, song, comment, comment description, year, track, total number of tracks, and genre.
I use either v2strip or the id3v2 packages to strip the tags. If you have one and not the other just comment/uncomment the appropriate one.

While this script shouldn’t do any unreparable damage to your files always test first on a copy.

———————-

#!/bin/bash

## Description: This script will traverse a directory, find mp3s, strip all ID3 tags(both ID3v1 and ID3v2),
## then re-tag them based on the directory structure.
## Existing file structure MUST be ./artist/album/song.mp3
## Depends: id3lib – http://id3lib.sourceforge.net
## id3v2 – http://id3v2.sourceforge.net
## v2strip(optional) – google it if you distro doesn’t have it.

IFS=$’\t\n’

for i in $( find . -iname ‘*.mp3′ )
do

# Let’s get the existing tags out of there.

id3v2 -D “$i”
# v2strip “$i”

if [ -f "$i" ];then

artist=$(echo “$i” | awk -F/ ‘{print $2}’)
album=$(echo “$i” | awk -F/ ‘{print $3}’)
title=$(echo “$i” | awk -F/ ‘{print $4}’)

nice -n 19 id3tag -2 –artist=”$artist” –album=”$album” –song=”$title” “$i”

fi
done





Getting Zenwalk 6.2 To Work On The Aspire One ZG5

19 01 2010

The 6.2 install is exactly the same as 6.0. While the Fn key tweaks are also the same, the Xorg.conf tweaks no longer work and the kernel needs to be recompiled to include a couple of modules for the card readers to work. Here I’m going to deal with my biggest pet peeve. The card readers.

As most people know the righthand card reader does not work very well out of the box. You have to have a card inserted at boot for it to work. Sort of assinine. Now the solution was simple for 6.0 because the kernel packager included the modules required to hotplug the card. Well in the stock Zenwalk kernel (2.6.30.5) and even the Snapshot kernel (2.6.32.2) they weren’t included. So this is how I recompiled my kernel to included them.

1) Download & Install the Zenwalk kernelsource. It doesn’t matter whether your Current or Snapshot. Open terminal and follow the example

m4x[~]$ su
Password:
root[m4x]# netpkg kernelsource
Cleaning cache
Connecting to mirror
Uncompressing meta information
Computing packages dependencies
Computing packages descriptions
Creating packages list
Getting local packages list
Computing packages status
cat: /var/netpkg/last_selector: No such file or directory
Synchronization with http://distro.ibiblio.org/pub/linux/distributions/zenwalk/i486/snapshot successful
[I][extrad] Found installed kernelsource-2.6.32.2-i486-64.1.tlz on the repository
what should I do ?
1) install
2) download
3) skip

Pick number 1.

After it has install as root we need to change directories. So now

m4x[~]$ su
Password:
root[m4x]# cd /usr/src
root[src]# ln -s linux-2.6.3x.x linux (replace the x's with the kernel version you installed)
root[src]# cd linux
root[linux]#

Now you should be in /usr/src/linux. Now let’s get ready to configure our new kernel.

root[linux]# make mrproper
root[linux]# cp /boot/config .config
root[linux]# make prepare

Let’s give your kernel a new version.

root[linux]# mousepad Makefile

Now we are going to edit line #4. Add your version after the last digit in the line. I’ve added m4x.
EXTRAVERSION = .2m4x
Save and quit.
Now let’s open the configure tool.

root[linux]# make gconfig

Once open we are going to add a couple of modules to be built.
Scroll down to Bus options (PCI etc), expand it.
Scroll down to Support for PCI Hotplug(NEW), double click it. There should now be a M in the value column.
Scroll up to PCI Express Support(NEW), expand it. Double click PCI Express Hotplug Driver(NEW). There should now be a M in the value column.
Save and exit program.

Let’s build it

root[linux]# time nice -n -19 make

When it is finally done building we’ll install it

root[linux]# make modules_install
root[linux]# cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.32.2m4x
root[linux]# cp System.map /boot/System.map-2.6.32.2m4x
root[linux]# cp .config /boot/config-2.6.32.2m4x
root[linux]# depmod -v 2.6.32.2m4x

Now your kernel is install, but we have to point lilo to it and we have to add stuff to the kernel line.

root[linux]# mousepad /etc/lilo.conf

Now add pciehp.pciehp_force=1 to the append line.
It will look something like this

# Start LILO global section
append="resume=/dev/sda3 splash=silent pciehp.pciehp_force=1"

Now let’s make a new entry for your new kernel. Mine looks like this.

# Linux bootable partition config begins
image = /boot/vmlinuz-2.6.32.2m4x
root = /dev/sda4
label = 2.6.32.2m4x
initrd = /boot/initrd.splash
read-only
# Linux bootable partition config ends

Save and exit program.

Run lilo

root[linux]# lilo -v

Now we just have to get the pciehp module to load at boot.


root[linux]# mousepad /etc/rc.d/rc.modules

Add /sbin/modprobe pciehp to it, save and quit program.

Now reboot and select your new kernel.
Hopefully everything goes well. If your card reader doesn’t work open a terminal as root and

root[linux]# modprobe mmc_block

Good Luck





Kuki 3.0 Pre Release 1.7

25 06 2009

So I thought I would try out the Kuki 3.0 Pre Release 1.7. There seems to be a decent following over on the Acer Aspire One User forum.

Just a couple lines from the kuki site.

Kuki Linux is a lightweight Ubuntu-based Linux distribution founded by João Ferro (leak), built to be a replacement for the Linpus Lite distribution on the Acer Aspire One.

It uses XFCE 4.6 as a window manager and features lightweight software and all the fixes to allow the Acer Aspire One to work as well as possible.

So as a replacement everything should work out of the box. Well let’s see how it meets my requirements.

1. It is a live distro and I was able to use Unetbootin to put it on a usbkey.
2. Not particularly fast but it still booted. I was able to walk downstairs, grab a glass of water and return in time to see the login screen pop up.
3. Wireless out of the box. Led doesn’t work, but that isn’t important to me.
4. Screen real estate. Only one panel was in use, so that’s not bad.
5. Card readers. Neither readers worked out of the box. Do they have to be inserted prior to boot? I tried to modprobe pciehp and was returned a nice FATAL: Module pciehp not found. So I guess that is a FAIL
6. Sound card. Well it works sorta. When I opened a mp3 I was greeted with volume at max and an error AO: [pulse] Failed to connect to server: Internal error. I was unable to lower the volume by scrolling over the volume applet but I could raise and lower via the function controls and the mixer controls. So this is a niggle.
7. Webcam works out of the box.
8. Suspend does work, but not from Fn+F4. So this is another niggle.
9. Fn+Fx keys, not all work. As a matter of fact only F7(mousepad) and F8(mute) work. Had this been a generic distro it would be fine, but this is built especially for the Acer Aspire One.
10. Overall feel. Well it just feels slow. Scrolling in Iceweasel is slow and stuttery. Switching between tabs lags. Scrolling through desktops is slow. There’s no Office packages other than a dictionary, pdf viewer, orage and zim desktop wiki. Gimp isn’t included. None of my existing partitions were setup to browse. It makes this distro useless as a livecd/usb. There really is nothing that makes me want to go wow.

Score: 4/10





My Aspire One Linux Distibution Requirements

23 06 2009

There has been plenty of discussion around as to what makes a good Linux distribution for the Aspire One. Everyone has their own special requirements as well as their favorite distros. So here are my requirements.

1. Must have a livecd. This is the most important feature because if the installed system go tits up this makes it easier on everyone if you are able to boot from a like system. This livecd should boot from a usb also. The distro should install nicely using Unetbootin. So many people are being told to use this utility to install the iso to their usb.
2. It must boot. No extra cheat codes unless it is language and keymaps. Time doesn’t really too much, but over 40s and it starts to get annoying.
3. Wireless. If wireless isn’t automatically detected and you have to figure out some new utility it gets fairly annoying. I believe ath5k has work fine since 2.6.28. If the developer wants to include madwifi drivers that isn’t a problem. It just shouldn’t take forever to setup. Remember, if you don’t have wireless it makes it hard to get online and troubleshoot. Not everyone is going to be able to use eth0.
4. Screen Realty. The AAO A150s only have an 8.9″ screen so having panels and widgets every where is just clutter.
5. Card Readers. Both just have to work out of the box. They are supported in 2.6.28 and newer, they need to work. The need to be built with the kernel. To rebuild the kernel on this little guy takes about 80 minutes. Having to remember to insert one in before booting is worthless also. Having to reboot because you forgot is asinine.
6. Sound Card. Sound is nice to have.
7. Webcam. Another nice thing to have working. It is supported in the newer kernels.
8. Suspend. A nice feature to have. Not very often do you find a distro that it doesn’t work, but sometimes you do.
9. Fn Keys. If a distro claims to be netbook compatible these have to mapped to something at least.
10. Overall Feel. Does the distro feel polished, was it hard to get around the desktop, did packages work, am I able to browse all disks, can I browse network shares easily? Just some things to make the experience better.

Yea, every distro is going to require some tweaking, but to be missing functionality is ridiculous.

Some distros I might not trty due to the fact they don’t have a livecd. I’ve got a working system on my AAO and don’t wish to install a distro that I’ve tweak the hell out of.

While I’ll be trying as many distros out I’ll post my opinions, maybe someone will find them useful.





Zenwalk 6.0 On Acer Aspire One

25 02 2009

Do Not Use This Tutorial To Install Zenwalk 6.2

I recently purchased one of Acer’s netbooks. The Aspire One ZG5. It’s blue, has 120GB hard drive, 1GB RAM and it had WinXP Home Edition on it. Now I can use Windows but I just don’t like to, I prefer Zenwalk Linux. Not Ubuntu, Debian, Fedora, Suse, Mandriva or any of their offspring. I figured if Acer could put Linpus on the AAO I should be able to install Zenwalk on it. There is more than enough information out there now to accomplish this.

Prep Work:

You need to upgrade your AAO’s bios to 3309. A simple Google will give you the answer.

Steps

1) I was planning on keeping WindowsXP so I was going to have to set this up for dual booting. So defragment the hard drive.  I’m going to resize the Windows drive and don’t really want a bunch of files scattered all over.

2) Resize the drive.  My AAO came with a 120GB drive so I left the recovery service partion intact (PQSERVICE 4.88GB). Resized the WindowsXP (ACER) down to half @ 53.45GB.

3) Create a Linux partition. My linux partion is 52.45GB and formatted  with Ext3.

4) Create a Linux Swap partition of 1GB.

Now all I really had to do was reboot and make sure Windows was still there and worked. Yup

Shopping List:

UNetbootin – A small utility that will download and install several different linux distros to a USB key and make it bootable.

USB key large enough for the Zenwalk ISO.  I had a 1GB key laying around.

Zenwalk 6.0 iso

Beer

Install:

1) Go ahead and use UNetbootin to install the Zenwalk 6.0 iso to the usb key. Fairly simple task so I won’t explain it.

2) Reboot the AAO. Upon reboot hit F12 to select a boot device. Select your usb key. Then hit enter when the boot menu comes up. You should now be in the Zenwalk setup. You should just be able to hit enter again to start the installation process. You should now be confronted with a dialog screen with several options such as autopartition,partition and exit. We are going to exit the installer, so select exit and hit enter and then you should now be in a command line. We did this because Zenwalk 5.2 and newer does not like to be installed from a usb, it will eventually error out towards the end  complaining it can’t find the packages to install. So now we are going to mount the usb key for us to use later. This is what I used.

mkdir /usb1
mount /dev/sdb1 /usb1
setup

Now we should be back in the installer.

3) Now that we are back to the installer, it is as simple as just answering questions. First select your keymap, then go straight to install. The install dialog will find your linux swap partition and your ext2 partition. It will ask you what filesystem you wish to use and format it. I chose xfs. It will find your Windows partion and the Acer recovery partion. It will ask you where you wish to mount these. I chose /mnt/Acer and /mnt/Win_XP. Now it should be ready to install the Zenwalk packages. You are going to choose the premounted directoy option. Just enter where you mounted the usb key: /usb1 . Hit enter.

4) While it is installing go have a beer. Come back in about 20 minutes and when it’s done have it install lilo. Select the simple, and a resolution of 800×600, no extra options, mbr. Reboot.

5) Now just finish up with the postinstall. You’ll have a functioning Zenwalk 6.0 install minus your SD card readers, and your Fn keys.

Card Readers:
To get your card readers to work is pretty simple.
1) Open xkernelconf. This can be found in System >> Control Panel.
Scroll down the right side of xkernelconf and doubleclick mmc_block and pciehp. Now apply changes.
2) As root create  /etc/modprobe.d/pciehp and add options pciehp pciehp_force=1 to it.
3) Reboot and insert card in either slot and the will be seen in Thunar.

Xorg.conf:
The Intel graphics run a little slow with the stock Xorg.conf. Simply add

Option "AccelMethod" "exa"
Option "MigrationHeuristic" "greedy"
to the driver section of xorg.conf and

export INTEL_BATCH=1
to /etc/profile.

Fn Keys:
The Fn keys seem to take the longest to setup. While I could get most working with just one program, I was not able to get them all working properly. I ended up combining several techniques.

First we need to add some lines to /etc/rc.d/rc.local
As root add the following to rc.local
/usr/bin/setkeycodes e025 130
/usr/bin/setkeycodes e026 131
/usr/bin/setkeycodes e027 132
/usr/bin/setkeycodes e029 122
/usr/bin/setkeycodes e071 134
/usr/bin/setkeycodes e072 135

Now as your user create .Xmodmap with the following contents.
keycode 160 = XF86AudioMute
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 223 = XF86Standby
keycode 239 = XF86KbdBrightnessDown
keycode 123 = XF86KbdBrightnessUp
keycode 210 = XF86Display

Now open ~/.xinitrc in mousepad and add to it.
xmodmap ~/.Xmodmap

Now go into the XFCE Keyboard setttings and add these commands to the appropriate Fn keys.

amixer set Master 2dB+ unmute >>> FN + UpArrow
amixer set Master 2dB+ unmute >>> FN + DownArrow
amixer set Master toggle >>> FN + F8
sudo /usr/sbin/standby >>> FN + F4

As of now the Fn keys F4,F6,F7,F8, Brightness Up, Brightness Down, Volume Up and Volume Down will work at your next login
If Fn+F4 does not put your AAO into standby you might have to correct it.
Open terminal and if
your_username[~]$ sudo /usr/sbin/standby
returns
sudo: can't stat /etc/sudoers: No such file or directory
Segmentation fault

then
su
mv /etc/sudoers.new /etc/sudoers

Now Fn keys F1,F2,F3 and F5 require a little more work.
First we need a small package called xbindkeys, so open a terminal and
su
netpkg mirror
netpkg xbindkeys

Now as your_username open terminal and
xbindkeys --defaults > ~/.xbindkeysrc
mousepad ~/.xbinkeysrc

Remove everything after
# Examples of commands:
then add

# F1 XFCE4 Help
"iceweasel /usr/share/xfce4/doc/C/index.html"
m:0x0 + c:134
# F2 Zen Panel
"gksu zenpanel"
m:0x0 + c:135
# F3 powersave
"xfce4-power-manager -c"
m:0x0 + c:140
# F5 External Display
"/usr/bin/externaldisplay"
m:0x0 + c:210

Now we need to add xbindkeys to XFCE’s startup.
Which is in Settings Manager >> Sessions and Start Up >> Application Autostart. Click the ‘Add’ button and fill in the name as xbindkeys and the command as xbindkeys.

You’ll notice how I use Fn+F5 to call /usr/bin/externaldisplay. Basically externaldisplay is a simple xdialog script that changes the resolution on an external monitor. My script is:

#!/bin/sh
DIALOG=Xdialog
$DIALOG --title "External VGA Display" \
--menu "Choose a Resolution" 13 50 6 \
"1" "Laptop Only" \
"2" "Ext.Monitor Only 1024x600" \
"3" "Ext.Monitor Only 1024x768" \
"4" "Ext. Monitor Auto" 2> /tmp/menu.tmp.$$
retval=$?
choice=`cat /tmp/menu.tmp.$$`
rm -f /tmp/menu.tmp.$$
case $retval in
0)
if [ "$choice" = "1" ]; then
xrandr --output LVDS --mode 1024x600
xrandr --output VGA --off
fi
if [ "$choice" = "2" ]; then
xrandr --output VGA --mode 1024x600_60.000
xrandr --output LVDS --off
fi
if [ "$choice" = "3" ]; then
xrandr --output VGA --mode 1024x768
xrandr --output LVDS --off
fi
if [ "$choice" = "4" ]; then
xrandr --output VGA --auto
fi
;;
1)
echo "Cancel pressed.";;
255)
echo "Box closed.";;
esac

If you wish to use this for your needs you’ll have to find out the resolutions your external monitor is capable of. You can do that by first connecting your monitor and then in a terminal issue

xrandr -q








Follow

Get every new post delivered to your Inbox.