Hello, and welcome to my blog! I post sporadically on random subjects from Linux to Emacs. Check out my tags if you want to browse posts on a specific subject.

If you want to be notified about new posts, this blog has an Atom feed feed. However, unless you want to read my every rant, you may want to subscribe specific tags instead, each of which has its own Atom feed. Most feed readers will correctly deduplicate entries so you shouldn’t run into any issues if you subscribe to multiple tags.

Apt Repository Permissions

Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.

I just posted a solution to this idea but thought that I should share it here.

Here is the problem: In order to get the latest features on Ubuntu, people are adding a lot of PPAs. For now there hasn’t, as far as I know, been a case in which a PPA owner has uploaded a malicious package but this is a possibility. Uploading an end user application, such as shutter, with malicious code would be problematic but not devastating. On the other hand, uploading a malicious sudo package would be devastating. Here is my solution.

Different repositories would “own” packages:

  1. Ownership would be set in a file such as /etc/apt/ownership/.list
  2. A special system packages file would be created that would designate system packages (sudo, pam etc…).

Apt repositories would have permissions:

  1. Ultimate Trust: Update and Install packages from this repository regardless of ownership including system packages.
  2. All: Update and Install new packages from this repository regardless of ownership (except system owned packages).
  3. Owned only: Update and install only owned packages.
  4. No Updates: Install owned packages from this repository but do not download updates from it.

Flags:

  1. Warning: There would be a warning flag that a user could set on a repository that would warn when packages are updated or installed from that repository.
  2. System: There would be a system flag that could be set on security related packages (sudo, bash etc…) that would prevent all but “Ultimate Trust” repositories from installing/updating them.

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…

  1. Download my script (via copy and paste) from here. Lost (email if found).
  2. Save the script somewhere where you will not delete it and mark it as executable (chmod u+x /path/to/script.sh)
  3. 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.
  4. 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.
  5. Now either log out and then in or run ’/path/to/script.sh init' in order to remap the capslock key.
  6. 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

  1. 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.
  2. 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 type libxul and get libxul0d.

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:

  1. Go to My Files in the web interface.
  2. Create a new folder (to be shared) with the person that you will be inviting
  3. Go to the sharing tab (on the right).
  4. 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).

http://ubuntuone.com

For anyone looking for an invite, just ask @bugabundo at Identi.ca.

Grdc - A very good graphical VNC viewer for the average linux user

Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.

Overview

After finding myself frustrated with Vinagre’s (GNOME’s standard VNC viewer) lack of ssh tunneling support I began looking for an alternative. I finally found it: Grdc.

Grdc supports both VNC and RDP. Grdc can tunnel both connections over ssh for security. The ssh tunneling supports key based or password based authentication and allows the user to select a custom server and port (if they differ from the defaults).

Grdc’s user interface is much simpler than that of Vinagre. It allows the user to create and save custom connections and organize them by groups. Its connection quality settings are, unlike many remote desktop programs, quite simple. The user simply chooses the quality and the number of colors. Grdc also has a panel applet for the gnome-panel that lets users connect to their saved connections through a simple menu.

Another interesting feature is the “VNC Incoming Connection” protocol. This protocol lets users create new VNC servers with custom ports and passwords on the fly. This is especially useful if a user wants to let a remote user temporarily control their desktop.

Grdc does not support everything. It does not support tabbed connections like Vinagre but, in my opinion, tabbed connections are overkill for most users. It also does not support browsing a network for VNC connections with avahi as Vinagre does. This feature would be useful for administrators but is somewhat useless for the average user because most users will access the computer from the internet, not the LAN, and thus avahi support would be pointless.

Overall, Grdc is good for remote, internet traversing connections because of its ssh support and is useful to the average user because of its simplicity. Vinagre is still a better VNC client for administrators that have to manage many computers over a LAN because, on a LAN, encryption is usually unnecessary while avahi support is helpful and, when managing multiple computers, tabs are very helpful.

For screenshots see the SourceForge Screenshot Page

Installation

As of the writing of this post, the version of Grdc in the ubuntu repositories is woefully out of date and does not support ssh tunneling. Therefore one should use the deb provided by the project maintainers on sourceforge. Simply download the grdc deb (link below) and install (usually just double click). The grdc-gnome package is the gnome-panel applet and the grdc package is the main program.

Downloads: http://sourceforge.net/project/showfiles.php?group_id=248852

Homepage: http://grdc.sourceforge.net/

– Edit: I have packaged a 64bit version. Download here.

– Edit 2: The 64bit version of grdc-gnome (the panel applet) for karmic seems to work in jaunty. Download here.

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.

  1. Install pavucontrol and the gnome-sound-recorder (in the gnome-media package).
  2. Open the gnome-sound-recorder and start recording
  3. Open the pulseaudio volume control and switch to the recording tab
  4. 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.

Identi.ca feed fetcher script

Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.

Attached is a simple Identi.ca feed fetcher script written in python. It is a console program and has no gui. It will display the same content as would appear on a users Identi.ca homepage for a given user. Edit the configuration at the head of the script before use.

It works well with conky; simply add ${exec python /path/to/script.py} to your conky file and it will update whenever your conky refreshes. If your conky config is set to update very frequently, please use ${execi interval /path/to/script.py} so that you are not constantly polling identi.ca’s server.

  • Edit 1: Updated script to correctly encode text and to include replies.
  • Edit 2: Inline script to fix broken link.

Script:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright (C) 2008 Steven
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Blog: http://blog.stebalien.com

import feedparser
import textwrap
import unicodedata
### SETTINGS ###
# Username (lowercase)
USER = "stebalien"
# Width in charictars of output
WIDTH = 50
# Number of posts to display
POSTS = 10

# Indent of posts
INDENT_FIRST = 3
INDENT_REST = 5

################

def formatPost(string):
    #string = string..replace(unicode("“", "utf-8"), '"').replace(unicode("”", "utf-8"), '"').replace(unicode("…", "utf-8"), '...').replace(unicode("’", "utf-8"), "'")
    string = unicodedata.normalize('NFKD', string).encode('ascii','ignore')
    parts = string.partition(':')
    return parts[0] + parts[1] \
    + "\n" + wrapper.fill('\n' \
    + parts[2]) \
    + "\n\n"

wrapper = textwrap.TextWrapper()
wrapper.subsequent_indent = ' '*INDENT_FIRST
wrapper.initial_indent = ' '*INDENT_REST
wrapper.width = WIDTH
# Get and display feed
all_feed = feedparser.parse("http://identi.ca/" + USER + "/all/rss")
reply_feed = feedparser.parse("http://identi.ca/" + USER + "/replies/rss")

n = 0
i = 0

while ((i+n) < POSTS):
    while (reply_feed.entries[n].updated_parsed > all_feed.entries[i].updated_parsed):
        print "> " + formatPost(reply_feed.entries[n].title)
        n=n+1
    print "  " + formatPost(all_feed.entries[i].title)
    i=i+1

Banshee Plugin for mumbles

Caveat lector: I wrote this post in high school; it’s likely outdated and poorly written.

I Just wrote a banshee plugin for mumbles. It works much better than banshee’s default notification daemon integration. Clicking on the notification brings banshee to the front. Install it like you would any other mumbles plugin (see two posts back or look for instructions on the mumbles homepage).

Plugin (python 2.5) + Source: banshee-plugin_mumbles.tar.gz