Here's a sixth omnibus post. This one has been a long time coming. I started the first draft of it back before I was working at Barzel, shortly after the last one, but it always got delayed by other things, and I'm discovering things more slowly now. The
first five are still
available for viewing.
Restoring GRUB as the Bootloader
I owe this one to
A Complete Dose of Linux Poison. I needed to reinstall Windows, however I had a fair amount of work invested in the Linux half of my new desktop, so I didn't want to reinstall it. However, Windows overwrites the Master Boot Record (MBR) when it installs, effectively cutting off access to any other partitions' operating systems which you might want to use. I hear there is a Microsoft solution for setting up multiple Windows boots, but I don't know what it is. I did a great deal of research, since I didn't have very many options for implementing a solution if I ruined Linux too. Here's the solution I successfully implemented:
When you're anticipating a GRUB failure (like you're about to reinstall Windows), you can make an image of the MBR with dd:
sudo dd if=/dev/sda of=[image_path] count=1 bs=512
sda can be whatever your hard drive device path is (hda for IDE hard drives), bs counts 512 bytes count times, if and of refer to input and output files.
After you mess up the MBR, you can put it back by running any live disc like Knoppix or Ubuntu that can mount the path where you put the image and running the command:
dd if=[image_path] of=/dev/sda
I have not tested the alternate, after the fact solution, which involves booting with a live CD that has GRUB on it:
sudo grub
> root(hd0,0) hard drives and partitions are numbered ordinally to GRUB, pick your favourite
> setup(hd0)
> exit
Apparently this may not regenerate the Windows part of the GRUB menu, but that's less difficult. The GRUB commands (in /boot/grub/menu.lst which generates the GRUB menu) which worked for Mindslave, after my crashed SUSE install were:
rootnoverify (hd0,1) It was a Dell computer, which for some reason means that the first partition was Dell-related.
makeactive
chainloader +1
boot
That was one of my first entries in my Linux notebook. *sniff*
Note: This is for Grub 1. I can make no promises that this applies to the new version of GRUB, which I haven't tried at all.
amixer: Command Line Volume Adjustment
This was also motivated by not having a multimedia keyboard, and the volume knob is by my toes; I needed a way to adjust volume fast and I mapped this one to hotkeys too (until I ran out, damn you Metacity!)
amixer scontents gives you a pretty complete list of everything you can fiddle with. Apparently there's support for multiple sound cards. I haven't explored that.
amixer set
Command:You can "mute", "unmute", or "toggle" the muting status, however some devices can't be muted (it returns "Invalid command!"). The previous volume level is restored when unmuted.
Value:You can set absolute value in bits (different maximum scales for different controls), percentages (get rounded off or truncated, so they don't always report as having changed by that percentage), or decibels (with 0.00dB being 100% output, so everything else is a negative value).
Change:Same as value, but append a + or - sign.
xmms2
In Windows, I use Winamp, on Mindslave, I used xmms which had a very similar interface. I liked that there was little more to the basic interface than a playlist and play controls. I just wanted something that played music. I didn't experiment much with other players, but I wrote most of them off because their screenshots looked annoying. I installed xmms2, figuring it would be more or less the same as xmms, but then found out it was only a daemon, and required command-line control. Well, that was fine, but then I couldn't find a GUI client I liked. I mapped key commands to hotkeys, and eventually mangled the xmms desklet into serving my needs, using the iexec control to manipulate the command line.
You send commands to the daemon with xmms2 . A great number of the commands are documented in the man page, and are pretty intuitive, like play, toggleplay (toggle with pause), next and skip <+-seconds>.
There are two tricky aspects. You can get live status information with xmms2 status or a one-time output with xmms2 current '${variable1} {variable2}' where and are any of the values recorded in the media library (syntax may vary based on substitution rules of your favourite shell, I can never keep mine straight). The that is conspicuously missing is the progress through the song, I have yet to figure out how clients like gxmms2 get that information from the daemon.
A Little Bug in Metacity
When you're setting up hotkeys like I've mentioned before with Metacity, despite the schema help text, the Page_Up key will only be recognized with that capitalization. Lowercase and the key doesn't get set.
Disabling the Screensaver, Redux
In omnibus number five, I referred to two methods to suspend the screensaver, and chose one. Updates to Ubuntu (I'm now running Karmic) have rendered my preferred one, xdg-screensaver obsolete (or at least irritating, now one has to look up a hex code handle for the screen session, instead of that one convenient value. Thus, it is much easier to use a third technique, based in Gnome and rolled into a script:
#!/bin/sh
#Use xdg-screensaver to toggle screensaver suspension
OUTPUT=`gconftool-2 --get "/apps/gnome-screensaver/idle_activation_enabled"`
if [ "$OUTPUT" = true ]; then
OUTPUT1=`gconftool-2 --set "/apps/gnome-screensaver/idle_activation_enabled" --type boolean false`
else
OUTPUT1=`gconftool-2 --set "/apps/gnome-screensaver/idle_activation_enabled" --type boolean true`
fi
I subbed this into my script, linked it to a hotkey, and use
gconftool-2 --get "/apps/gnome-screensaver/idle_activation_enabled"
in my gDesklet script to retrieve the status of the screensaver.
wget:Spotty Connection Download Utility
wget is extremely useful when I've got a spotty connection. Use the -c option to continue downloading from where the file was left off, -t [num] to specify a number of times to try when the download fails (which on a spotty connection can be frequently) or inf for infinite, -b to download in the background.
Sharing One Firefox Profile Between Multiple OS's
This hack is unpleasant, and I'm not sure how well it's working. It was necessitated by the Firefox 3 rethinking of bookmarks from a simple HTML file to a more complicated format. Formerly, I could point both versions of Firefox to the bookmark file, now I needed to share the profiles completely (or use a plugin like Foxmarks to sync via the web). You need to pick some suitably shared drive (I chose my shared data drive, which is FAT32, because I don't really trust the Windows ext drivers, nor Linux' NTFS writing), and then run firefox -profilemanager in both Linux and Windows, and create a profile that points to the common location.
This is the only variable I can think of that I haven't tracked down for why Firefox is really slow in Linux.
Screen
Screen allows you to connect and disconnect processes from a given command prompt. For example, if you run btdownloadcurses which uses an all-ascii interface for a BitTorrent GUI, then press ctrl-a and then d, you get back to the command prompt. You can list the screen sessions which are active with screen -ls and then reconnect to one of them with screen -r [PID]. If there is only one active screen session, then you can omit the identifier number.
This is cool, because it opens up possibilities for remote activity on a computer. Previously, I only knew how to interact with things related to daemons on the host computer. I could play with xmms2 remotely (I think it would be an amusing prank to have my Desktop suddenly blare music late at night, while I'm away, and Emily's home alone), but not with bittorrent (it would be nice to be able to remotely check on stuff, maybe set up a dedicated file server on Mindslave (old, but not dead yet), so that I could be more free to switch OS's on Calculatrix. It's even possible that I could use this to get around some issues I'm having with the xmms desklet I've been working on, though I think that might be overkill.
To-Do List
- investigate mencoder for it's dvd ripping ability
- get gDesklets to show information for multiple CPU's
- repair snapped speaker cables
- figure out how the Places menu automatically mounts stuff
- figure out if floppy drive works, and how to mount it, or swap in one from Mindslave
- set up a tty to continually show system log
- document for future use my issues getting Python in gDesklets to pass variables by reference
And the doozy:
- get my gDesklets up to a point where I would feel comfortable publishing them