Tutorials & Tips
Posts explaining how to do something, fix something, etc. This is where you’ll find my useful posts.
Unfortunately, given how software evolves over time, I should probably say “once useful”. If you’re digging through the archives, check the dates.
Start conky only after the root window loads
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
Every time I logged in, conky would start up before nautilus loaded the desktop. This caused conky to load as a floating window that stayed on top of all other windows. I have finally gotten around to fixing this problem.
Here (gone, email if found) is a simple python script that waits for nautilus to load the desktop before starting conky.
I stored the script referenced in this post in a paste-bin and now it’s gone. Live and learn…
This script is probably very inefficient but it gets the job done.
Humanity Icon for Caffeine
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
For those who don’t know, Caffeine is a small program for Linux that lets a user prevent his or her computer from entering a power save state. If a user wishes, he or she can even configure caffeine to automatically inhibit power-saving when watching a flash movie, or running VLC, Totem etc. For more information, visit its website here.
As a user of both Caffeine and the new Humanity icon theme (the default icon theme in karmic), I made a very basic gray-scale version of the Caffeine icon. You can download it here.
Write a file as root from a non-root vim.
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
Problem
I often edit config files in vim, try to save them, and then realize that I ran vim as a normal user and the config file is in /etc. In the past I would close vim and redo all of my changes as root (using sudo). This is a real pain especially if I had made a lot of changes.
Solution
Add the following to your ~/.vimrc:
cmap w!! w !sudo tee % >/dev/null<CR>:e!<CR><CR>
A while ago I came across this post that describes how to save a file as root from a non-root vim by adding cmap w!! w !sudo tee % >/dev/null
to my .vimrc
.
The problem is that, after running this command, vim will notice that the file has changed on disk and ask the user if he or she wants to reload it. After a while this got annoying, therefore the multiple CRs (enters) and the :e! (reloads the file).
Navigate text with vi(m) keys on linux
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
Intro
Lifehacker recently posted a AutoHotkey script for windows that allows text navigation using letters instead of the arrow keys. In response to @wersdaluv’s post, I wrote a very simple script that allows users to navigate text using the standard vim keys (hjkl) when the caps-lock key is toggled. Feel free and add to my very basic script.
Steps
I stored the script referenced in this post in a paste-bin and now it’s gone. Live and learn…
- Download my script (via copy and paste) from
here. Lost (email if found). - Save the script somewhere where you will not delete it and mark it as executable (
chmod u+x /path/to/script.sh
) - Add the script to the startup programs with the argument
init
(i.e./path/to/script.sh init
). If you don’t know how to add startup programs in your Desktop Environment, Google it. - Assign F13 (the now remapped capslock key), as a hotkey in your window manager. Set the command to
'/path/to/script.sh toggle'
. Again, if you don’t know how to add a hotkey, Google it. - Now either log out and then in or run ’
/path/to/script.sh init'
in order to remap the capslock key. - Pressing the capslock key should now toggle navigation mode.
Bash completion with aptitude aliases
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
Problem
- If I used my alias for installing an application (
inst application
), I would have to know the full application name because I would not have bash completion. This was very annoying when installing libraries because they often have weird version strings tacked on to their ends. - If I used the full command (
sudo aptitude install application
), I would have bash completion and would therefore not have to know the whole application name. I could simply typelibxul
and getlibxul0d
.
On one hand, I would type a short command plus a complected application name, on the other I would type a long command and a simple application name. I wanted to be able to type a short command with a simple application name.
Solution
I wrote my own bash completion rules. They are based on the default aptitude bash completion rules but customized for aliases.
# Install Completion
#
_aptitude_all()
{
local cur dashoptions
COMPREPLY=()
cur=`_get_cword`
dashoptions='-S -u -i -h --help --version -s --simulate -d \
--download-only -P --prompt -y --assume-yes -F \
--display-format -O --sort -w --width -f -r -g \
--with-recommends --with-suggests -R -G \
--without-recommends --without-suggests -t \
--target-release -V --show-versions -D --show-deps\
-Z -v --verbose --purge-unused'
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
else
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
fi
return 0
}
_aptitude_installed()
{
local cur dashoptions
COMPREPLY=()
cur=`_get_cword`
dashoptions='-S -u -i -h --help --version -s --simulate -d \
--download-only -P --prompt -y --assume-yes -F \
--display-format -O --sort -w --width -f -r -g \
--with-recommends --with-suggests -R -G \
--without-recommends --without-suggests -t \
--target-release -V --show-versions -D --show-deps\
-Z -v --verbose --purge-unused'
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
else
COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
fi
return 0
}
complete -F _aptitude_all $default inst
complete -F _aptitude_all $default upgrade
complete -F _aptitude_all $default apt-info
complete -F _aptitude_all $default apt-changes
complete -F _aptitude_all $default apt-download
complete -F _aptitude_installed $default uninst
complete -F _aptitude_installed $default reinst
complete -F _aptitude_installed $default purge
Just copy it into a file such as ~/.bash_completion
and source the file in your ~/.bashrc by adding “. ~/.bash_completion
”.
Change/Add/Remove the aliases at the end of the file. The lines that start with complete -F _aptitude_all
complete any available or installed package and lines that start with complete -F _aptitude_installed
complete only installed packages.
inst, upgrade, apt-info, apt-changes…. are my aliases. You must use YOUR ALIASES for this to work. To add aliases, read this.
How to invite someone to Ubuntu One
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
For anyone with an Ubuntu One account, the following are instructions for sending invites:
- Go to My Files in the web interface.
- Create a new folder (to be shared) with the person that you will be inviting
- Go to the sharing tab (on the right).
- Share the folder with the person that you want to invite (The trick is that someone does not have to have an Ubuntu One account to accept a share).
For anyone looking for an invite, just ask @bugabundo at Identi.ca.
How to record one's linux computer with pulseaudio
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
I posted a simple tip to an Identi.ca user (mxc) explaining how to record a skype conversation and felt that others might find the information useful. Here is an elaborated explanation of how to record the sound from a linux computer.
- Install pavucontrol and the gnome-sound-recorder (in the gnome-media package).
- Open the gnome-sound-recorder and start recording
- Open the pulseaudio volume control and switch to the recording tab
- Click on the down arrow of the “gnome-sound-recorder” Record Stream, Select “Move Stream” and move the stream to the “Monitor” stream for your sound card.
This should record all sound from your computer if you are using pulseaudio. I have not tested this with skype but it should work.
Change the notification icon in Mumbles without creating a plugin.
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
I have noticed that several people have asked how to change the notification icon on mumbles without creating a new plugin.This is actually very simple: use the generic DBus plugin with dbus-send. I believe that this tutorial requires the SVN version but I may be mistaken. First add a new section to your DBus plugin configuration file. If you do not have this configuration file, copy the sample one from the mumbles source tarball (found on the project’s homepage). The file is called dbus.conf.sample
. Copy this file to ~/.mumbles/dbus.conf
. The new section is as follows:
[program-or-script-name]
enabled = true
interface = org.program-or-script-name.DBus
path = /org/program-or-script-name/DBus
signal = your-signal
icon = your-icon.png
Put your-icon.png in the ~/.mumbles/plugins/icons/
folder.your-signal is your name for the alert. None of these variables are important but they must be consistent.
After doing the previous and restarting mumbles, run this command:
dbus-send /org/program-or-script-name/DBus org.`*program-or-script-name*`.DBus.your-signal string:"Title" string:"Message"
Make sure that you replace all necessary variables. This will display a mumbles popup with your custom icon, title, and message. You can also specify a click action using launch = action
.
Mumbles with gmail
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
I have been playing around with mumbles lately and have written a gmail plugin for anyone interested. Mumbles is a notification system that works very much like growl for the mac. The latest SVN version can even replace the gnome notification daemon (but not very well). While still in its infancy, this project shows a lot of promise. I based the plugin on the evolution tutorial on project’s homepage. I based the script on this script (with many modifications). When you click on the notification popup, evolution will launch (you can edit the source to change the program). The script requires python-feedparser.
Plugin, Source, and Script package: gmail-plugin_mumbles.tar.gz
Installing the precompiled plugin:
Do step 2 from the next section. Now copy the plugin to
~/.mumbles/plugins/
.
Installing the plugin from source (adapted from dot_j’s tutorial (gone)):
1. Download the source
Download the package and extract. Then open a terminal window inside the plugin-source folder.
2. Create the directory structure and choose an icon
Run the following command:
mkdir -p ~/.mumbles/plugins/icons
Then either run this to use the default evolution icon…
cp /usr/share/icons/hicolor/22×22/apps/evolution.png ~/.mumbles/plugins/icons
Or just copy your desired icon into the plugins/icons folder and rename it to
evolution.png
. This is unnecessary if you already have the evolution plugin.Build and install the plugin
cd ~/gmail_plugin python setup.py bdist_egg
This will use our
setup.py
file to create our plugin. After it runs, you should see a file namedGmailMumbles-0.1-py2.5.egg
in the dist directory that was created by the build process. Here the-py2.5
part of the filename refers to what version of python you are using (it may vary, but if you are able to start mumbles, should not matter).The .egg file is our plugin, so the only thing left to do is copy that to the mumbles plugin directory.
cp dist/GmailMumbles-0.1-py2.5.egg ~/.mumbles/plugins
Installing the script:
Find the script in the package and edit the username and password variables. Run this script with
python /path/to/gmail.py
(replace /path/to with the path to the script). By default, this script will check for new email every 2 minutes and alert the user of new mail.
BTW: This script does not safely store the username and password. I may, in the distant future, make this script work with gnome-keyring but this is not likely. I hope that mumbles will soon get better notification-daemon support so that I can go back to using mail-notification.
Running the "Ubunu System Panel" on a 64 bit machine.
Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.
After installing the 64 bit version of Ubuntu on my Dell Inspiron 1420n I found that the USP (Ubuntu System Panel) keybindings do not work. This is because the /usr/lib/python2.4/site-packages/usp/plugins/_keybinder.so
is compiled for a 32 bit system. After a little searching I found out that Glipper includes a _keybinder.so
file. After replacing USP’s _keybinder.so with Glipper’s version, the keybindings worked fine.
- Download glipper
aptitude download glipper
. - Extract the glipper deb with
dpkg-deb -x glipper_1.0-1ubuntu1_amd64.deb glipper
(change glipper_1.0-1ubuntu1_amd64.deb to the name of your file). - Copy in the new _keybinder.so with
sudo cp ./glipper/usr/lib/python-support/glipper/python2.5/glipper/keybinder/_keybinder.so /usr/lib/python2.4/site-packages/usp/plugins/_keybinder.so
. - Restart USP with
killall gnome-panel
and your USP shortcut keys should now work.
Edit: This is no longer necessary.