My Scripts and Programs

Programs

Musik Open Source Music Creator

Musik is my only publicly-released program. It takes text such as

C4 D4 E4 F4 G4 A4 B4 C^4

and translates it into audible music. It supports the following:

You can download the current version (version 3.0 released 11/08/2016) here:

(Note: Due to the fact that I am too poor to afford a Mac and my Hackintosh virtual machine broke, I will no longer be compiling for OSX).

Musik is released under the GPL version 3.0 (or later). Go to GitLab.

I have also written other programs, but have not released them.

Scripts

Since I have started using Linux, I have developed a couple of scripts to make my life easier.

iw enhanced

This shell script + Haskell program can be used to find a specific SSID (useful if you use iw to figure out the authentication parameters for a certain SSID, since the associated parameter in iw appears to be broken). The shell script is pretty simple:

The Haskell program is a bit more involved:

Save the shell script as whatever you want (and mark it executable), and save the Haskell program as parse_wifi.hs somewhere in your path (and mark it executable). Calling this is pretty simple — simply type the name of the script followed by the SSIDs you wish to filter for or type --list to list all of the available SSIDs. Side note: Yes, they say we shouldn't screenscrape iw. No, I don't care. I will keep this script up to date if the format of the output changes 😉

Appify

This shell script can be used to create a shortcut to any website using a .desktop file. It takes two inputs - the website and the name of the menu item - and creates a .desktop file which launches Firefox with the specified website. This means it automatically appears in the menu in the Gnome, KDE, and XFCE desktop environments. The script can be found here.

EZmail

Ah - the wonders of mailing lists. I started a club at school and needed to email all of the members at once, preferably without any interaction from me. At first, I resorted to emailing each member individually, but I knew that could not stand for long. Out of necessity, I was forced to come up with a script which would save the day. I use a command-line email client called mutt, which is capable of accepting an address, a subject, and a body. It will then automatically email the person with the subject and body I specify. I then came up with a script which passes each address in the addresses argument to mutt with the subject and body arguments also specified, optionally with an attachment also specified. The code is given below:

All of the arguments, with the exception of the attachment, are plain text documents. The addresses file is set up with one address per line. The subject and body files are just plain text files. This script was inspired by the Windows-only program febootimail and serves my purposes well.

NitroRoto - Rotating Backgrounds for Linux

I currently use Debian Linux and use a program called Nitrogen to set the wallpaper. I wanted rotating wallpapers, but Nitrogen does not support that. I looked around and found some scripts which will randomly select a wallpaper from all of the images in a given directory. However, that did not work for me because I have my images sorted into four folders. Therefore, I decided to try modifying the script I found. However, once I started trying to modify it, I figured out I had to pretty much write it from scratch. The script I came up with is shown below:

The only things similar to the original script are the variable names.

QuickRename

This simple script looks for files matching a certain extension pattern and renames it to the new pattern.

Both the extension to replace and the extension to replace it with are passed as arguments to the script. Technically, this script could be used to replace any sequence of characters at the end of files/folders - that "sequence of characters" just happens to be the extension most of the time.

SmartPlaylist

This simple script simply adds smart playlist functionality to MPD/MPC (my music player of choice). The script itself is fairly simple.

It reads in the file (the only argument to the script), parses it (I will explain the syntax in a minute), and replaces the current MPD playlist with the playlist generated by the script (I believe that is how most smart playlists work - if you only want to ever add songs, comment out the line mpc clear; and SmartPlaylist won't clear the current playlist). Now what does a typical SmartPlaylist file look like?

The first value is the category you are searching and the second value is the value you are searching for within that category. You can use any search category that is a valid search category for MPC (the MPD client this script uses).

SimpleBackup

Any good computer user knows that they should back up their documents and other files. I knew I should be backing up my stuff, but I hadn't found any good, simple, backup programs for Linux. Hence, I created my own shell script that does the job for me.

This script will efficiently backup your data (provided you configure it correctly). The only things you should have to change are BACKUP_ROOT (change to point to the directory you want to back up to - everything will end up inside this directory), SOURCE_ROOT (change to point to the directory that everything you want to back up is in - usually, the home folder will do), files (change to the list of files and folders you want to back up), and possibly rsync_args (the arguments you would like to pass to rsync - the defaults I have provided should be sufficient). File and folder names should not contain spaces. In addition, this script saves a couple of key files like /etc/hosts, /etc/default/grub, the list of sources, and the list of installed software. However, this is particular to Debian and Debian-based distributions, so you may need to modify it for your distribution.

sCard Converter

The sCard format is a simple and logical way to store your contacts. A sample entry would look something like this:

First Name : Last Name : Phone1 \n Phone2 \n Phone3 : Email1 \n Email2

However, the columns aren't predefined. That is, another sample entry could look something like this:

Last Name : First Name : Email1 \n Email2 : Phone1 \n Phone2

This renders the format much more flexible than other formats for two reasons:

However, there are a couple of problems with the format. It is not accepted by any major email clients or phones, and it doesn't look that pretty. Enter the sCard Converter. This simple Python script converts from the sCard format to LaTeX (to make it look pretty) and vCard (to allow you to import your contacts into phones and email clients). The one catch is that if one is exporting to vCard, one must specify the headers at the top of the file. The header must use vCard compatible header names (full list here) followed by square brackets denoting how many columns the header should combine. For example, if the entry is:

First Name : Last Name : Phone1 \n Phone2 \n Phone3 : Email1 \n Email2

then the corresponding header would be:

FN[2] : TEL[1] : EMAIL[1]

As mentioned earlier, the header row must be the first row in the sCard file. You might as well always write a header row because the LaTeX export ignores it anyway. The LaTeX export will output a LaTeX table which you can then \include into a full LaTeX file to get a pretty address book! The vCard export will output a vCard file that should be compatible with most (newer) phones and almost all webmail/email clients. The script also lets you choose which column to sort by. The script can be found here.

SimpleTag

This simple Python script uses extended attributes (supported by all common filesystems (although OS X programs apparently delete them)) to store tags for files and folders. The script allows adding tags, deleting all tags for a given file, removing specific tags for a given file, listing currently used tags, and searching for files with a specific tag. It requires the xattr module. That module apparently only supports Linux, Mac OS X, FreeBSD, and Solaris at present, although I have successfully tagged files on an NTFS file system.

I have developed other scripts, but they are not as useful as these and are mostly fixes for certain issues I was having at the time.