A text based text enlarging tool ;)

So recently I have been playing with PIL in Python as I attempted to convert on the fly picture from my web camera to text-graphic… Yeah, I know, it doesn’t even sound right! This project is working but I havent called it yet done – when it is I certainly will publish it here.

Meanwhile (out of boredom) I wrote this tiny script that takes a string that then gets converted to a black&white picture which then gets interpreted a pixel by pixel and printed to the terminal with different character where a pixel belonged to black colour and different where it was white.

It’s easier to explain with an example so this is an output of the following command:

$ python ./text_magnifier.py "dodgydomain.com" 15

dodgydomain.com

The font can be specified within the script – I went for the TTF type of fonts.

I had no purpose for this script when writing it but I imagine it could be used to generate some MOTD (Message Of The Day) content or whatever else…

The script can be cloned from it’s repository here:
https://bitbucket.org/mironq/terminal-string-magnifier
Hope you enjoy it.

Posted in Programming | Tagged , , , | Leave a comment

A bluetooth started song on a MPD server

This is a very simple Python script that I put together some time ago. I had only two goals on my mind when writing this: see if I can and fun. Both goals were achieved.

The script uses bluetooth module to scan for bluetooth device in surroundings and compares it with those provided in script itself. If it encounters a matching device then it will attempt to connect to the MPD server and play selected song. If the song is not on the current play list then it will try to find it in the library, add i to the play list and play.

I ran this script at my work desktop (Ubuntu with bluetooth dongle) and triggered it with my phone’s bluetooth (by enabling it and making visible) for couple of days when entering the office I felt like the Lord Vader with imperial march was started upon my arrival.

Full script can be obtained from my Bitbucket Git repository, below are only few “configuration” lines:

Define device and music track:

user3 = {
'bt_addr':'BC:F5:AC:84:8B:33',
'owner':'Mirek',
'song':"VA-Essential_Film_Themes/210-va-star_wars_episode_v_the_empire_strikes_back.flac",
'title':"The Empire Strikes Back",
'start_second':'10',
'welcomed':False
}

The “bt_addr” is of course the address of the bluetooth device that will trigger the action. The “song” holds a full path to the selected track from point of view of the MPD’s media library where “title” is a piece of title of the song by which we would be able to locate this one specific song in the whole MPD library – it will be used to find and add the track to the current playlist shouldn’t it be there already. “start_second” tells the MPD where to start the track – our track my start from specific moment for greater effect.

All that’s left is to ensure that it will be loud enough to bring an attention:

client.setvol(55)

And start playing at selected moment:

client.seekid(theid,10)

The only issue I had with this is that it usually takes some time for the bluetooth device to be discovered and therefore it’s hard to synchronise with the music. Nevertheless it was fun for me and I hope it will be some use to you also.

Full script can be cloned from with following repository:

https://bitbucket.org/mironq/bluetooth-mpd

Posted in Programming | Tagged | Leave a comment