Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like
Programming
The “easy” way to listen to internet radio in Ubuntu
Jul 15th
I started with rhythmbox like most new Ubuntu users. It seemed nice enough but not in the area I was concerned with, internet radio. I tried out many players but was disappointed with different areas of different players. From Ubuntu 8.04 to 8.10 I was using the “good” Amarok (for KDE 3.5). Disappointed by the exclusion of that version in Ubuntu Jaunty 9.04 and unimpressed with workarounds like the PPA’s, I decided to play the field. I came across Exaile, which I’ve blogged about in the past. It’s a good enough player… most of the time. It crashed too often for my likings and I’m getting sick of pkilling it.
It struck me today that I needed a simplier more streamlined solution for my simple needs. I needed a console application. Through a little research, I found moc, which happens to play shoutcast streams as I’ve become accustom to.
I then proceeded to set myself the following way:
sudo apt-get install moc mkdir -p ~/Music/internet_radio && cd ~/Music/internet_radio wget -r -l2 -nd -Nc -A.pls http://www.di.fm/index.php for file in *.pls; do mocp -a $file; done mocp
1) Installed moc
2) created a directory to download all the playlists from di.fm (since this is the station I listen to most often)
3) wget all the playlists
4) add them all to moc
5) start moc and [tab] to the play list side, enter to play
enter -- starts playing
s -- stops playing
n -- plays next item from the playlist
b -- plays previous item from the playlist
space -- pause
p -- pause
S -- plays at random
R -- repeats the same song in a loop,
Next (X button below) must be OFF
X -- switches to play sequentially
o -- plays a file from the Internet
u -- moves playlist item up
j -- moves playlist item down
Ctrl+u -- adds the URL to the playlist
g -- searches marked string in file names
/ -- searches marked string in file names
r -- rereads the directory
T -- switches to the theme selection menu
f -- toggles display mode of song titles
TAB -- switches marker bar between the playlist
and the file manager panels
l -- switches between displaying the playlist
or the file manager panel
P -- switches full path in the playlist
H -- toggles hidden files view
Ctrl-t -- toggles song duration time
Ctrl-f -- toggles format file view
m -- moves to directory entered in config file
G -- moves to directory with currently played file
i -- moves to marked directory
U -- moves to upper directory
a -- adds a file to the playlist
A -- adds a directory recursively to the playlist
C -- clears the playlist
V -- saves the playlist
d -- removes marked item from the playlist
Y -- removes all empty items from the playlist
< -- decreases volume by 1%
, -- decreases volume by 5%
> -- increases volume by 1%
. -- increases volume by 5%
x -- toggles the mixer channel
? -- shows help
! -- goes to a fast dir 1 (set in config file)
@ -- goes to a fast dir 2
# -- goes to a fast dir 3
$ -- goes to a fast dir 4
% -- goes to a fast dir 5
^ -- goes to a fast dir 6
& -- goes to a fast dir 7
* -- goes to a fast dir 8
( -- goes to a fast dir 9
) -- goes to a fast dir 10
F1 -- executes ExecCommand1 (set in config file)
F2 -- executes ExecCommand2
F3 -- executes ExecCommand3
F4 -- executes ExecCommand4
F5 -- executes ExecCommand5
F6 -- executes ExecCommand6
F7 -- executes ExecCommand7
F8 -- executes ExecCommand8
F9 -- executes ExecCommand9
F10 -- executes ExecCommand10
Above commands from polish linux’s article on moc audo player, great resource.
codepad.org – an online compiler/interpreter, and a simple collaboration tool.
May 27th
codepad.org is an online compiler/interpreter, and a simple collaboration tool.
NautilusSvn – Finally an SVN GUI for Linux that doesn’t totally suck
Apr 28th
Now I know that headline may upset some people but from when I originally switched from Windows as my primary desktop, to up until ~a few months ago, I was at a loss for a decent SVN GUI in Linux. The SVN clients in the [Ubuntu] repositories were unstable, quirky or just total garbage.
The first I tried was Rapid SVN, rated high in the ‘add/remove’ programs dialog. I found this very unstable. Next I tried eSvn which I also found unstable and quirky. Then unto KDE svn which seemed quite stable and solid actually… but unfortunately I use GNOME and this application is (obviously) for KDE, so naturally(?), there were some bugs. In particular the title bars and some other variables were not passing values properly, they would show up as literal %t or what have you. This was a deal breaker for me. Smart SVN came recommended and I agree, it has potential but it seemed to be too much for my simple needs and hell, if I’m going to run a Java application, I might as well switch my IDE to Eclipse and use the plugin for that (which is actually a good interface to SVN).
However, I love my current IDE, Geany and I don’t use SVN strictly for code projects. Some of the Ninjaz and I collaborate in mapping using SVN.
For a while I used svn in the terminal, which is really as minimal as you can get and to a degree, I really enjoy it. It also makes for good practice when I need to do things concerning SVN on a server. However, this is 2009 and I (usually) feel more efficient with a GUI.
In windows, my favorite SVN client was Tortoise SVN, the de facto standard in SVN for windows. After tireless research I finally came across the application I was dreaming for, Nautilus SVN, which is attempting to clone Tortoise SVN for Linux. Written in Python, it integrates itself nicely into Nautilus’ right click (context) menu. When I first started using it, the application was pretty barebones but with the latest release, it has come a long way. Bringing in nice emblems and icons to signify status and accompany menu options, it’s really starting to feel like a solid application.
At version 0.12 beta, it’s obviously got some minor bugs but nothing that stands out… too hard. There is currently an issue with the status checks responsible for the folder emblems that can cause nautilus to temporarily freeze while retrieving information from large repositories but the problem is being addressed, though they’ve hit a few snags along the way.
I talked with one of the developers, Bruce from the Netherlands on their IRC channel, #nautilussvn on irc.freenode.org and feel confident in direction of the project. Bruce is a really nice and informative guy which makes the project all the more interesting to me.
I wish the team the best in the future and I’ll definitely be sticking with this for a while, I suggest other GNOME users check it out as well.
Batch images conversion – color to transparency from the linux terminal
Mar 31st
I’ve been re-theming and old forum and the themes that are available are a little less than perfect for our needs. I found a few suitable templates but it still results in me creating a mash-up. Some of the images (though gif) set the image background color to that of the site background. As I was using a different color, this obviously looked bad but I wasn’t about to manually edit all the files to give them transparency.
Being aware of the amazing command line tool for Linux, ImageMagick, I set out to find a tool to help me. I found a transparency flag, calculated the RGB values with the eyedropper in GIMP, then after a test run, I through it in a for loop.

So a directory down from my image source, I created a folder called “new” and ran the following color and like magic, they were all converted.
for image in *.gif; do convert -transparent 'RGB(48,71,94)' $image ../new/$image; done
Creating a simple news script that reads from an XML file
Mar 29th
I recently recoded a website for a friend because his markup was pretty ugly (thanks to WYSIWYG editors). While I was doing that, he mentioned he’d like to have an xml file he could edit to update his news. Simple enough I said and banged out the following which includes a little helpful function that wraps paragraphs in HTML p tags. My friend alpha helped me rewrite some ugly regex with a novel idea:
Of course, he’s a big perl coder so I had to create a php equivalent, nls2p.
Edit: Mookow mentioned he wanted to write links, so obviously a system would have to be put in place to support this. Using HTML tags in XML gets a little sloppy so I opted to use bbcode which is a very popular method to format text in web applications and very simple to add more filters.
The news post creator:
<?php if (file_exists('news.xml')) { $xml = simplexml_load_file('news.xml'); foreach ($xml->post as $post) { echo "<h4>".$post->title." - ".$post->date."</h4>\n"; echo "<div>".bbcode(nls2p($post->content))."</div>\n"; echo "<p>--".$post->author."</p>\n"; } } else { echo "<p>Failed to open news source</p>"; }
The functions for formatting:
// Wrap paragraphs with <p> tags function nls2p($str) { $split_str = preg_split('#[\t]+?[\r\n]{1}#',$str); foreach ($split_str as $line) { $new_str = $new_str."<p>".preg_replace("/[\t\n]/","",$line)."</p>\n"; } return $new_str; } // Parse bbcode as HTML function bbcode($string) { $search = array( '@\[(?i)b\](.*?)\[/(?i)b\]@si', '@\[(?i)i\](.*?)\[/(?i)i\]@si', '@\[(?i)u\](.*?)\[/(?i)u\]@si', '@\[(?i)img\](.*?)\[/(?i)img\]@si', '@\[(?i)url=(.*?)\](.*?)\[/(?i)url\]@si', '@\[(?i)code\](.*?)\[/(?i)code\]@si' ); $replace = array( '<b>\\1</b>', '<i>\\1</i>', '<u>\\1</u>', '<img src="\\1">', '<a href="\\1" target="_blank">\\2</a>', '<code>\\1</code>' ); return preg_replace($search , $replace, $string); } ?>
The XML data file:
<?xml version='1.0' standalone='yes'?> <news> <post> <title>Site looks update</title> <date>03-29-09</date> <author>Moo</author> <content>The site has been completely recoded by a friend of mine, -z- from NexuizNinjaz.com. He even added this fancy news script. Now, to update the news, I don't even have to touch index.php! Alright, I'm out for now. OMG A [b]NEW LINE[/b]! Now with [i]italics[/i] and [u]underlines[/u] and [url=http://www.nexuizninjaz.com]links[/url] [code]code blocks[/code] and images [img]http://www.xepic.net/pics/pic_091622001182920068.jpg[/img] </content> </post> <post> <title>Site looks update</title> <date>03-29-09</date> <author>Moo</author> <content>Yeah, I removed the stupid gray background, because after a while it got boring. I changed the "Random Shiznit" column into something that could be a bit more productive. Once all of the other sites are up, I'll update the main page with the latest news from those. This main news column will be for the more intriguing news. I also decided to add titles to the news articles...Duuhhhhhhh OMG A NEW LINE! and again, LOL! </content> </post> <post> <title>Site looks update</title> <date>03-25-09</date> <author>Moo</author> <content>I added a boring gray background to the main page, as you can see. The hover text-changing effect was removed because of its stupidity. A cool guy named Fabzor re-colored the header for me.</content> </post> <post> <title>Site looks update</title> <date>03-23-09</date> <author>Moo</author> <content>Website updated, not much. Cool hover effects were added, but we still don't have much color in the page. Hopefully, I can find a good background and get this show on the road.</content> </post> <post> <title>Site just started...</title> <date>03-22-09</date> <author>Moo</author> <content>Most of the links up top will not work for the time being, this site is just getting edited. Soon, we'll have a better webpage than this one, but for now, deal with this one!</content> </post> </news>
That’s pretty much it verbatim, including mookow’s news ^_^. Hope this is helpful to someone.
Finding files and strings using the terminal in Linux
Feb 4th
My favorite thing about Linux is the terminal. I use it countless times a day to do all sorts of tasks, like managing game servers or writing scripts to do tedious tasks. One of the most popular things I do in the terminal is search for files or strings inside of files and today I’d like to go over a few methods and tricks for doing this. There are three tools that make this task amazingly easy but combining them is where we find the real power. These three tools are locate, find and grep. I will cover the basic use of these tools with some examples and tricks but I suggest you take a look at the man pages for the tools for addition information (i.e. man locate).
locate
Locate has got to be the most straight forward way to search for files. It uses a database so it’s blazing fast when searching your entire computer, compared to the ‘find’ we’ll cover later. It’s not available by default on all Linux distributions (it is on Ubuntu) so you might have to install it. Since I’ll be mentioning fstab later, I’ll give my examples with it.
Basic syntax is: locate [filename]
tyler@quadjutsu:~$ locate fstab /etc/fstab /etc/fstab.orig /etc/fstab.pre-ntfs-config /etc/fstab~ /usr/include/fstab.h /usr/lib/udev/migrate-fstab-to-uuid.sh /usr/share/apps/katepart/syntax/fstab.xml /usr/share/doc/m4/examples/fstab.m4 /usr/share/doc/mount/examples/fstab /usr/share/doc/util-linux/examples/fstab.example2 /usr/share/man/man5/fstab.5.gz /usr/share/pysdm/fstab.py /usr/share/pysdm/fstab.pyc
This database will automatically update itself at various times but to force an update type the following command:
tyler@quadjutsu:~$ sudo updatedb
Folder exclusions can be found (and edited) in /etc/updatedb.conf
By default (at least in ubuntu) /media (your mounted media) is not included in this database. This means if you use extra drives you’ve added to your computer and you want them to be searchable through the locate tool, you’ll have to mount them to a directory like /mnt.
To mount a drive on boot, you’ll need to add a line like the following to your /etc/fstab. The one below mounts an ntfs drive to /mnt/mydrive. That folder must exist for the drive to be mounted.
/dev/sda1 /mnt/mydrive ntfs-3g defaults,locale=en_US.utf8 0 0
I found the /dev/sda1 part by listing my harddrive partitions using the following command:
sudo fdisk -l
find
Find is a little more cryptic than locate but it’s a very powerful tool that should be available on most Linux distributions if not all.
Basic syntax is: find [directory] -name “[string]” -print
Find will search recursively through the folder you’re calling it from. The directory isn’t required but it will show you the full path. A neat trick is to use $(pwd) which creates a string for the “present working directory”. It’s also a good habit to use quotes around your name search because you can’t do regular expressions without it. find does not do matching the same way locate does. You’ll have to specific a wild card (*) for partial searches.
tyler@quadjutsu:~/Desktop$ find -name "notes" -print tyler@quadjutsu:~/Desktop$ find -name "notes*" -print ./notes.txt~ ./notes.txt tyler@quadjutsu:~/Desktop$ find $(pwd) -name "notes*" -print /home/tyler/Desktop/notes.txt~ /home/tyler/Desktop/notes.txt tyler@quadjutsu:~/Desktop$ find -name "no[a-z]*" -print ./notes.txt~ ./notes.txt
My Buddy From Belgium, MrBougo has asked I make note that -iname makes it case insensitive.
grep
In the context of searching, grep is like a pocket knife. It’s great for limiting returned results and searching through files, which are my two most common uses of it, though I’m sure there are a million others. First I’ll cover the searching files for strings portion and in combined tools we’ll discuss how to refine search results.
In terms of searching strings in files, basic syntax is: grep “[string]” [filename]
grep is case sensitive but can be changed to insensitive with -i. You can access extended regular expressions (which allow for such functions as use of the + sign to signify 1 or more characters) by calling “egrep”
tyler@quadjutsu:~$ grep "tyler" resume.txt tyler@detrition.net tyler@quadjutsu:~$ grep "Tyler" resume.txt Tyler J. Mulligan tyler@quadjutsu:~$ grep -i "tyler" resume.txt Tyler J. Mulligan tyler@detrition.net tyler@quadjutsu:~$ grep -i "tyl" resume.txt Tyler J. Mulligan tyler@detrition.net tyler@quadjutsu:~$ egrep -i "tyler [a-z.]+" resume.txt Tyler J. Mulligan tyler@quadjutsu:~$ egrep "tyler [a-z.]+" resume.txt
MrBougo also mentioned that, grep returns a 1 exit status if it doesnt find, so grep “foo” && grep “bar” will only grep for bar when foo is found.
Combining the tools
There are two very important techniques for linking together commands in the terminal. The pipe | and &&. The pipe passes the output of one command to the next, the && runs a command after the one before is complete.
Starting off slow, we’ll refine our search of grep with another grep. Note that you don’t have to use the quotes as I’ve shown below.
tyler@quadjutsu:~$ grep -i "nexuiz" resume.txt * Web Developer and Interaction Designer for Nexuiz / Alientrap * Owner and Creator of Nexuiz Ninjaz tyler@quadjutsu:~$ grep -i "nexuiz" resume.txt |grep -i ninjaz * Owner and Creator of Nexuiz Ninjaz
Not that you would really want to do the follow commands but to emphasize how | and && work, the following example shows how you’re running the command twice rather than refining a search:
tyler@quadjutsu:~$ grep -i "nexuiz" resume.txt && grep -i "ninjaz" resume.txt * Web Developer and Interaction Designer for Nexuiz / Alientrap * Owner and Creator of Nexuiz Ninjaz * Owner and Creator of Nexuiz Ninjaz
Recalling our first example with fstab, there was a lot of extra results we didn’t want. We know know it was in the etc folder, so we can filter our results by that.
tyler@quadjutsu:~$ locate fstab |grep etc /etc/fstab /etc/fstab.orig /etc/fstab.pre-ntfs-config /etc/fstab~
Another way would be to EXCLUDE folders we don’t want with the -v flag.
tyler@quadjutsu:~$ locate fstab |grep -v usr /etc/fstab /etc/fstab.orig /etc/fstab.pre-ntfs-config /etc/fstab~
And filtering out the junk like so:
tyler@quadjutsu:~$ locate fstab |grep etc |grep -v "~" |grep -v "\." /etc/fstab
~ has a special meaning in the terminal so you must quote it to match it. ~ refers to the user’s home directory, in this case /home/tyler. I’ve also had to escape . because it too has special meaning, in the context of regular expressions, it will match any character… if we’re excluding any character, we’re excluding our results
.
Quick Tricks
Remember commands is sometimes a hard thing to do, especially when it’s a whole string of complicated commands and regexes. Sometimes, I know I don’t have the mind to take notes but that’s okay (for a grace period) because bash keeps track for me. The history command will list all your recently executed commands and utilizing the grep command, we can filter that list.
tyler@quadjutsu:~$ history |grep locate 613 locate fstab 614 locate fstab |grep etc 624 locate fstab |grep etc |grep -v "~" |grep -v "\."
A quick way to search for files in a directory would be to use locate as the path and grep the results
tyler@quadjutsu:~$ locate ~ |grep notes.txt /home/tyler/Desktop/notes.txt
These are the basics of finding files and searching through them. Linux provides many tools to reformat and replace strings. There are a million different ways to combine commands and always a faster way to do it. Keep playing and you’ll just get better and better.
Most computer keyboards today suck…
Dec 3rd
I just trashed my Logitech MX Duo. Which I haven’t even used the mouse with in over a year. Not that I could, I ended up throwing that thing at a wall and stomping it to death after all the frustration it has caused me. Mind you, I’m not normally a violent person but this keyboard duo… boy howdy. The design is flawed in the fact that you have to DOCK THE MOUSE if you want to charge it. That means, you can’t use the mouse when it’s charging. Sure if I was more disciplined in the art of mouse charging, you could argue that the device gives me ample time to charge while I sleep for the usual 6-8 hours… but aside from the fact that getting the contacts to align properly meant 3 minutes of jiggling the damn thing in the dock, why not just use A STANDARD AC ADAPTER? This way, you can use your mouse when it’s charging. Is that not common sense?
A few other things I disliked:
- when it starts dying it exhibits random behavior that initial begs the question “what’s wrong with my computer?” — oh the keyboard’s just dying.. duh!
- the keyboard just started to randomly scroll documents when I was typing (not fun when trying to write final papers)
- KVM compatibility? HAHAHHAHAHA… AHAHAHAHAHA. no.
- You plug a big AC adapter that covers 2 plugs on a power strip, then an additional USB connection (st00p1d)
- don’t press the logout button by mistake!
Things I liked:
- wheel for volume, god yes
- simple, (arguably) helpful media buttons
- the insert, home, page up, delete, end and page down buttons are layed out the classic way
As a programmer, I prefer the classic:
Which my Dell Quiet Key I’ve been using to bridge the gap after I made the decision to abolish the evil MX Duo and receive thy bounty from Trust has
.
Anywho, the mainstream keyboards couldn’t seem to meet my expectations. Logitech came close but I don’t think I’ll ever buy Logitech again. I’m happy with my DiamondBack Razer mouse (the copperhead was a joke and broke rather quickly).
After some careful research, I found a brand that fit my picky needs, the Trust Multimedia Scroll KB-2200 which I was able to pick up for a mere $33.50 on Amazon. I’ve been using it for a little over a day now and I’m very pleased.

It feels like a very solid keyboard, I like the way it types. My only complaint is the backspace button. It’s the size of a letter key, that’s going to take some getting used to.
Ubuntu Window Management with Multiple Monitors, Window Effects and Default File Associations
Nov 25th
Multiple Monitors Window Management in Ubuntu
Moving your applications from one monitor to the next with hotkeys
I’ve been using multiple monitors for a while now, Starting with a 17″ CRT with a 19″ CRT and moving up to two 19″ LCD, then 3, then temporarily one wide screen and back to 2. Something I always loved having as a utility in ultramon that I couldn’t find in Ubuntu (Gnome) or any window manager for that matter, was the ability to move applications from monitor to monitor. I had assumed the search futile until I was searching about some questions I had concerning Compiz-fusion with dual monitors and I came about this thread on Ubuntu forums which brightened up my day. A fellow named gfixler posted a bash script that utilizes command line applications to move the windows.
For you multi-monitor users seeking salvation from removing your hand from the keyboard to move your application from one monitor to another, here’s the skinny on getting it setup using compiz-fusion, aka Advanced Desktop Effects, to set my keybinds.
1. Open a terminal and setup your prerequisites with apt-get:
sudo apt-get install wmctrl xprop xwininfo
If you get errors about x11-utils, just ignore them, this package will handle your needs.
2. Next, lets put the script somewhere you can call it, say “~/scripts”
mkdir ~/scripts && cd ~/scripts && touch movewin.sh && chmod +x movewin.sh && gedit movewin.sh
2. Paste the following code, find the first function “getNumberOfMonitors” and configure it to the number of monitors you have (default 2).
#!/bin/bash # swap_monitor.sh (original version) # Moves the active window to the other screen of a dual-screen Xinerama setup. # # movewin.sh (modified version) # allows movement of windows left and right between multiple monitors # # Requires: wmctrl, xprop, xwininfo # # Original Author: Raphael Wimmer # raphman@gmx.de # # Modified by: Gary Fixler # gfixler+bash@gmail.com function getNumberOfMonitors { # simply must be hardcoded # e.g. MatroxTripleHead2Go can service 3 screens, # but appears as only one monitor to the computer # change to your number of monitors echo 2 } function getMonitorWidth { numberOfMonitors=$(getNumberOfMonitors) monitorLine=$(xwininfo -root | grep "Width") monitorWidth=$((${monitorLine:8}/$numberOfMonitors )) echo $monitorWidth } function getActiveWindowID { activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)") activeWinID="${activeWinLine:40}" echo $activeWinID } function getActiveWindowHorizontalPosition { activeWinID=$(getActiveWindowID) xPosLine=$(xwininfo -id $activeWinID | grep "Absolute upper-left X") xPos=${xPosLine:25} echo $xPos } function getActiveWindowWidth { activeWinID=$(getActiveWindowID) xWidthLine=$(xwininfo -id $activeWinID | grep "Width") xWidth=${xWidthLine:8} echo $xWidth } function getActiveWindowCurrentMonitor { numberOfMonitors=$(getNumberOfMonitors) monitorWidth=$(getMonitorWidth) activeWinID=$(getActiveWindowID) xPos=$(getActiveWindowHorizontalPosition) i="0" while [ $xPos -gt $monitorWidth ] do xPos=$[$xPos-$monitorWidth] i=$[$i+1] done echo $i } function getActiveWindowPositionOneMonitorToTheLeft { monitorWidth=$(getMonitorWidth) currentMonitor=$(getActiveWindowCurrentMonitor) activeWinID=$(getActiveWindowID) xPos=$(getActiveWindowHorizontalPosition) xPos=$[$xPos-$monitorWidth] echo $xPos } function getActiveWindowPositionOneMonitorToTheRight { monitorWidth=$(getMonitorWidth) numberOfMonitors=$(getNumberOfMonitors) currentMonitor=$(getActiveWindowCurrentMonitor) activeWinID=$(getActiveWindowID) xPos=$(getActiveWindowHorizontalPosition) xPos=$[$xPos+$monitorWidth] echo $xPos } function changeActiveWindowMonitor { activeWinID=$(getActiveWindowID) if [ $1 -eq "0" ] then newXPos=$(getActiveWindowPositionOneMonitorToTheLeft) newXPos=$[$newXPos-5] else newXPos=$(getActiveWindowPositionOneMonitorToTheRight) newXPos=$[$newXPos-5] fi winState=$(xprop -id ${activeWinID} | grep "_NET_WM_STATE(ATOM)" ) if [[ `echo ${winState} | grep "_NET_WM_STATE_MAXIMIZED_HORZ"` != "" ]] then maxH=1 wmctrl -i -r ${activeWinID} -b remove,maximized_horz fi if [[ `echo ${winState} | grep "_NET_WM_STATE_MAXIMIZED_VERT"` != "" ]] then maxV=1 wmctrl -i -r ${activeWinID} -b remove,maximized_vert fi if [[ `echo ${winState} | grep "_NET_WM_STATE_FULLSCREEN"` != "" ]] then fulls=1 wmctrl -i -r ${activeWinID} -b remove,fullscreen fi # move window (finally) wmctrl -i -r ${activeWinID} -e 0,${newXPos},-1,-1,-1 # restore maximization ((${maxV})) && wmctrl -i -r ${activeWinID} -b add,maximized_vert ((${maxH})) && wmctrl -i -r ${activeWinID} -b add,maximized_horz ((${fulls})) && wmctrl -i -r ${activeWinID} -b add,fullscreen # raise window (seems to be necessary sometimes) wmctrl -i -a ${activeWinID} } function moveActiveWindowOneMonitorToTheLeft { changeActiveWindowMonitor 0 } function moveActiveWindowOneMonitorToTheRight { changeActiveWindowMonitor 1 } "$1" exit 0
3. Setup your hot keys with compiz-fusion. Go to System >> Preferences >> Advanced Desktop Effects. Inside “General Options“, click on the command tab (I apologize for my heinous blue links).
Use
scripts/./movewin.sh moveActiveWindowOneMonitorToTheRight
and
scripts/./movewin.sh moveActiveWindowOneMonitorToTheLeft
respectively
Per Application Window Effects in Ubuntu
Bring character and tickle your soul with per application window effects
Another cool feature Compiz-fusion has is window animations. My friend James Lindsay recently reminded me about Window Effects… which when I first install Ubuntu on my laptop, I experimented my butt off… but being a laptop… I just used simple ones I’d turn off half the time anyway. He asked me why I don’t use them on my desktop and I didn’t have a good reason. Well, now I have 2 good reasons to keep using compiz.
I made my Thunderbird use the airplane effect so when I send emails, it flys away and for Geany, I used the magic lamp for open, close, maximize and minimize (different speeds). It’s a fun little effect that breaks up the stiffness of the desktop.
Default File Associations in Ubuntu
geany > gedit
I was tired of gedit popping up when geany’s just as lightweight but more affective. So found a command and altered it a bit to make my default editor geany.
1. Open the terminal and create\open the following file:
gedit ~/.local/share/applications/defaults.list
If it’s blank, add “[Default Applications]“. If it’s not, find “[Default Applications]“.
2. Then, back to the terminal, grep the default files associations and replace gedit with your editor of choice
grep gedit /usr/share/applications/defaults.list | sed s/gedit/geany/g
Copy (ctrl+shift+c) and paste the output into gedit, below the “[Default Applications]” header.
3. Restart nautilus to load the changes (will close all your file managers that are open and blink/freeze your desktop for a second)
pkill nautilus
Good luck, have fun and happy coding
Bash script to convert pngs to jpgs, thumbnail them and generate forum code
Aug 11th
I’ve been working on a tutorial for Nexuiz Ninjaz that requires a lot of screen shots. I’ve been utilizing the command line tool scrot to take screenshots on specific windows. These images however, are large pngs because the scrot date pattern wasn’t working properly when I tried to generate jpgs while repeating the same command. I went forward knowing I could find a way to batch compress these pngs later. Figuring I might as well “add a turbo while I’m under the hood”, I opted to both thumbnail the images (duh) and generate the forum thumbnail code (VROOOM).
So, to convert pngs to jpgs, I created a bash script which uses mogrify to convert, compress and thumbnail them and sed to assist in generating the forum code.
#!/bin/bash # # Convert pngs to jpgs, thumbnail them and generate forum code # Created by Tyler Mulligan - www.doknowevil.net condir=converted if [ ! -d $condir ];then mkdir -p $condir;fi pagename="http://www.nexuizninjaz.com/pics/howtos/map_link_a_ninja/" # Convert to jpg and create thumbnails echo -e "backing up originals...\n" cp *.png originals echo -e "converting to jpg...\n" mogrify -format jpg *.png echo -e "copying to converted directory...\n" cp *.jpg $condir echo -e "creating thumbnails...\n" mogrify -resize 50% *.jpg for file in *.jpg ; do mv $file `echo $file | sed 's/\(.*\.\)jpg/thumb_\1jpg/'` ; done mv *.jpg $condir echo -e "cleaning up\n" rm *.png # Generate forum code for file in $condir/thumb_*.jpg ; do tempname=`echo $file | sed 's/thumb_\(.*\)/\1/'`; echo "[url=${pagename}${tempname}][img]thumb_${tempname}[/img][/url]" done
Future plans call for adding flags to support different image types, and including the ability to take screen shots and generate the forum code on a per screen shot basis.
Sorta Off Topic: I’ve taken a swing at frameworks be developing a new layer of organization on top of cfg files in nexuiz. I’ve thoroughly documented this scalable, fully customizable package I’ve dubbed the Ninja Pack for Nexuiz





