Skip navigation.

rantshoutwhisper

Posts tagged with "linux"

Local weather, wherever you are - Conky script

, ,

I've written a collection of weather scripts! This is one of the first times I've done a script, so I hope it works where you are. Here are the scripts working in my current Conky layout.

Here it is:

http://files.myopera.com/coreymwamba/files/weatherscripts.tar.bz2

I'll reproduce the README here...

Local weather scripts by Corey Mwamba

WHAT DOES THIS DO?
This collection of scripts finds out the location of the IP server to which you're connected, and from that it gets your nearest weather station. Then it uses a python-metar script to present the weather to you.

You could use it in a Conky script on a laptop to get the general weather conditions where you are at the time. You could, of course, look out of a window instead: but why would you want to do that when you could have a COOL SCRIPT tell you instead? Eh? Eh?

WHAT YOU NEED TO MAKE THIS WORK
As far as I am aware, you need an Internet connection and:

python-metar - this is the bit that finds out the actual weather! It may be called **pymetar** for your system.
wget - this downloads the various bits of information for the weather.
If you want to use it in a Conky script, you also need Conky.

THE SCRIPTS
iplocfind
This is a script that I did not write, but have modified. It finds out the latitude and longitude of your IP address. I imagine it's not incredibly accurate, but it's good enough here!
I don't think it'll work if you're doing some kind of proxy weirdness (for example, you're in Australia but using an IP address that says you're in Wales - you'll just get weather for Wales).

A bunch of Python scripts (ending in .py)
These are python-metar scripts. weather.py is a script that comes with the RPM, but slightly modified by me. From that script I made separate scripts for temperature, wind, sky conditions and water content/rain.
weather.py
weather-rain.py
weather-sky.py
weather-temp.py
weather-wind.py

a bunch of scripts that begin with the word "local"
These are the scripts I wrote to pull everything together. It sends the latitude and longitude to a JSON site on Geonames - it's this that finds your nearest weather station. The script then strips that output to just the ICAO code for the weather station and feeds this to the appropriate Python script.

localrain
localsky
localtemp
localweather
localwind
locality



It is these that you would call in a Conky script, but you can use them as commands:

Example - open up a terminal, and find out what the weather's like.
corey@corlap:~> localweather
Temperature: 12.0°C
Rel. Humidity: 87%
gentle breeze
Wind speed: 3.58 m/s (3 Bft)
Wind direction: 200 deg (SSW)
Pressure: 1015 hPa
Dew Point: 10.0 C / 50.0 F
Weather: Few clouds
Sky Conditions: mostly clear
Visibility: None



conky-local-weather
I've included an example Conky script, to show how it works.

HOW TO INSTALL
Unpack the archive - the scripts are all executable so it should "JUST WORK".

If you grab them from here, you'll have to make them executable. Here's how:
If you don't want to use a terminal
  1. pop open your file browser and go to the folder where you saved the scripts
  2. select all the scripts except conky-local-weather
  3. Use the File Properties or Properties menu item. In most graphical file browsers you can right click on the mouse and this will be listed in the menu
  4. Go to the Permissions tab and tick/fill the Execute box for the Owner, Group and Others
  5. Accept your changes - probably by selecting the OK button

using a terminal
cd /path/to/weatherscripts/
chmod a+x *
chmod a-x conky-local-weather


Either way is fine.

If you like, you can move them (as root) to /usr/bin BUT THERE'S REALLY NO NEED TO DO SO.

IF YOU'VE GOT A PROBLEM
I'm probably not the best person to fix it. I'm not actually a programmer and don't really understand a lot about script programming. I'm not even entirely certain I've chosen the most efficient way of doing this - it's just the way that makes most sense to me with the limited skills I have.

In short: it's unlikely I'm going to be able to help you. But I'll give it a go.

IF YOU CAN DO THIS BETTER
Then please feel free to do so.

Audio apps to avoid Linux Desktop Environment Lock In

, ,

"Hold on. Lock In?" says the Linux user. "Linux doesn't suffer from lock in. That's a Windows thing."

I'm afraid not. There's a bewildering choice of distributions, and it's getting easier to install them and start using them. But most of the distributions will use either GNOME or KDE. There's nothing wrong with that - they're good. But if you're thinking of changing over to Linux because you've heard it's lighter and faster than Windows and will work on older computers, then you have to factor in that a fair few applications won't work if you decide NOT to use KDE or GNOME. And that can cause issues.

I bring this up as someone who started off using GNOME, got switched to KDE with openSUSE, and now is on Fluxbox with no GNOME or KDE dependencies. I plumped for Fluxbox because for audio work, it's best to give as much processing power as you can to the bits that do the audio; but if you like using graphical things [like I do] then you need a window manager. Using a lightweight window manager like Fluxbox [or Openbox, or...] is ideal for this purpose - you can then pick the other tools you need to build up your desktop environment.

For my laptop I chose not to download any KDE or GNOME libraries [or as few as I could get away with]. This immediately discounted Rosegarden [which relies on KDE] and Ardour [GNOME], two of the most popular audio production programs for Linux, from my choices. It also cuts out K3B and Brasero.

But of course, all is not lost, because the choices are there - but some are not easy to find. So, this is an attempt to gather the apps I've tried and like into one place. There are some very obvious ones, but there maybe some you haven't heard of. They all fulfil the requirement of not needing KDE or GNOME libraries; not crash on my system immediately; and come with a GUI.

It's a short list.

Audio Editing/Digital Audio Workstations/Multi-Track Recorders/Sequencers
Traverso - takes a small amount of getting used to, but it is good. And small. What's great about it is that you can once you've laid out the tracks you can burn straight to CD with it.

QTractor - this program reminds me of Cubase, and is very easy to use. Few glitches in the MIDI, but nothing major.

Each takes the gamut of file formats. The main frustration with both of these programs is that you can only apply effects per track, instead of per clip or region of audio; that's why you'll probably still need Audacity if you want to do electronic music work. But recording a band they'd both do very well. Crossfades elude all three, unfortunately.

CD burning
This was and still is my major bugbear. Unfortunately there isn't anything as good as K3B except Nero, and so unless you use a terminal [which is not the point of this list] there isn't a totally satisfactory CD burning tool that does not rely on KDE or GNOME. I tried to try XCDRoast with no success; and Graveman is unsuitable for audio [although it might be fine for data].

I've already mentioned the CD burning part of Traverso; the CD burning part of that was preceded by daoism. Although it's not been maintained for a few years, it remains a sensibly-designed application. It only accepts WAV at 44.1kHz but at least you can layout the tracks as you wish or put index markers in a long recording. It works perfectly as a simple tool. For burning data, there's icrave's recorder - again very simple but it works perfectly.

Audio playing
Bear in mind that I'm the sort of person that doesn't really like music collection managers. I use the audio player on my computer to listen to things. I expect it to play a CD and pretty much any file I throw at it without getting upset. As I rarely watch DVDs not having video isn't a problem, but having the option is nice.
Programs that seemed to be perfect from the description failed to load - Aqualung and GMerlin being troublesome on my system. I don't like any of the interfaces for MPlayer, so I stuck with VLC, which has a very clean interface in the Qt version. As long as you use the non-free version of FFMpeg, VLC will play anything, including AAC files. On my system Alsaplayer works more smoothly, but doesn't accept AAC files.

I tried to understand the concept of MPD but couldn't. Sometimes you just want to load things up and have them playing music WITHOUT configuring a server.

Format conversion
The best of show for me here is audio-convert-mod which now does bitrate resampling as well; so you can record at 96kHz/24-bit WAV and take it down to 44kHz/16bit MP3 if you wish. Its interface is clean and sensibly laid out, so doing single or batch conversions is a doddle.

Notation Editors
In this category there is only one: Musescore. To my mind, it's the most complete one by miles in a sea of really basic programs. If you want to copy Bach scores, then most editors will be fine. If you really want to do some creative work, then Musescore is your best bet.

That's about it. If there are any more audio programs with a GUI but no GNOME/KDE dependencies, let me know!


Quick Fluxbox tip: how to have a unlocked Opera

, , , ...

When Opera runs on Linux it creates a lock file. The lock file prevents another instance of Opera starting up, which I guess is good, but if Opera suddenly crashes, then starting Opera again can be problematic. Occasionally the e-mail won't start up and you get a warning about the lock file being active.

A quick search produces the answer [bring up a terminal, type killall opera: go into the .opera directory, delete the lock file: start up Opera again] but it'd be easier if you could stop it from happening ever again.

And you can [well, I can in Fluxbox, anyway]. Replace your menu entry for Opera with

[MacroCmd {Exec killall opera} {Exec rm ./.opera/lock} {Exec opera}] (opera)

replacing ./.opera/lock for wherever your lock file actually is [but it's likely to be there].

Note I'm not using killall -9. That's because the system by default does a system clean-up after a normal killall command; but using killall -9 doesn't do this tidying. Also, it's a bit excessive for stopping a process: the standard command will do fine.

Fluxbox: The Deco Bitmask Mystery Solved!

, , ,

It took me ages to get this, and another discussion with mark-t on the IRC chat. Again, because I can't put this on the Fluxbox wiki [although there are signs this might be a menu option!] I'm sticking it here in the hope it helps someone out. In the apps file for Fluxbox you can control many variables. There's a pretty complete wiki page for this, but one of the things not fully explained is

[Deco] {NONE|NORMAL|TOOL|TINY|BORDER|TAB} Specify the decoration state. There are several predefined decoration sets:

  • NORMAL - standard decorations
  • NONE - no decorations
  • BORDER - like NONE except keep the X window border
  • TINY - titlebar with an iconify button
  • TOOL - titlebar only
  • TAB - like NONE except show external tabs only
A bitmask can also be used for fine-grained control. The bits are (from "1" to 1<<10): titlebar, handle/grips, border, iconify button, maximize button, close button, menu enabled, sticky button, shade button, tabbing enabled, focus enabled.

What's a bitmask? I kept asking. What does "1" to 1<<10 MEAN? What am I supposed to put? Each bit-property is given a value that's based on a power of 2 in ascending order:
Property Value
titlebar 1
handle/grips 2
border 4
minimize button (called iconify) 8
maximize button 16
close button 32
enable window menu 64
sticky button 128
shade button 256
enable tabbing 512
enable focus 1024
You pick the things you want and then add up the values. So if I wanted a titlebar with just a close button I'd do 1 + 32 = 33 and then enter [Deco] {33} in my apps file. Although I suspect it won't work if you've set where your titlebar buttons should be in a style... But as proof it DOES work, here's a picture of a terminal with just a border [exaggerated so you can see it: unfortunately I haven't found a way to set the border width per window]... and yes, I could have just used the keyword, but you just have to check these things sometimes.

Displaying iCal events in Conky WITHOUT Google Calendar

, , ,

Conky is used to write various bits of information to your desktop/workspace. It has lots of scripts written for it which will display weather, news and a whole lot more...

...except iCalendar events from a local file. There is a workaround by signing up to Google Calendar and downloading any of the various scripts; but I can't really see the point in signing up to a calendaring service when you have a calendar already.

So I found a simple, crude way of getting what I want. I can't format it [and perhaps someone can help with that?] but at least it works. Simply get Calcurse and import your iCal file into it [you have to run Calcurse from a terminal]. Then go to your .conkyrc file and add

${execi 3600 calcurse -a -r 7}

Under the TEXT section. This will display your appointments for the next seven days. You can find other options by reading the Calcurse documentation, which is well-written.

XTerm: copying to the clipboard an easy way

, ,

Xterm is the simple commandline window that comes with most distibutions of Linux. Copying and pasting are not obvious, to say the least. Text just has to selected with the mouse to be copied; but that text goes somewhere called the primary buffer. From reading this, I suspect it's a standard. But it has to be said that I don't really understand it, and I'm not certain I should have to.

There are pages that will tell you how to change the behaviour so that your text goes to the clipboard: but these didn't work for me. So if they aren't working for you, here's another solution.

You'll need to edit your menu. I'm on Fluxbox, so I open up a text-editor and open up ~/.fluxbox/usermenu. I suspect you could use Alacarte or Kmenu for Gnome and KDE respectively.

Find the entry for xterm and replace what you have with

xterm -xrm 'XTerm*selectToClipboard: true'



So in Fluxbox the entry would be

[exec] (terminal) {xterm -xrm 'XTerm*selectToClipboard: true'}



Then save. When you open xterm and select text with a mouse, it goes to the clipboard. Where you thought it would go in the first place. You can still paste the text into another terminal with Shift+Insert: but you can paste into pretty much everything else with Ctrl+v.

I read the man page for xterm, which is how I thought of doing this. But the fact that I had to think about it, read the man page and then guess until it worked is quite frustrating.

Fluxbox: combining commands in a user menu

, , ,

Yes, this should be on the Fluxbox wiki... but asking for an account is long and slow.

I wouldn't have known about this unless I hadn't had a long IRC with a user called mark-t, who was helpful enough to finally give me the answer, but not so that he (or she, perhaps? Who can tell with the Internet?) wanted to tell anyone else.

SO...

The basic Fluxbox menu will probably not suit your needs, and it's a very easy thing to build your own. There is a basic guide at http://fluxbox-wiki.org/index.php?title=Editing_the_menu which tells you MOST of what you need to know.

What is not clear from the page is that there is a way to have more than one program started up at the same time; and also a way to have a toggled state.

The (much more complete) man page hints to this: it states that any legal key command can be used as a menu item. The difference (which is also not explained in the man page!) is that it has to be written in the form

[command {Exec program_1}...{Exec program_n}](label)



The two commands you might be interested in here are MacroCmd, which allows you start two processes one after another; and ToggleCmd, which gives you a switch (although you won't be able to see the state of the switch - maybe a Fluxbox wish?)

So, if I wanted to launch Psi and Opera at the same time, my menu entry would be

[MacroCmd {Exec psi} {Exec opera}](psi-opera-megasymbiotic-launcher)



And if I wanted to toggle JACK:

[ToggleCmd {Exec jackd} {Exec pkill jackd}] (Jack)



Simple really. Just not explained. Welcome to Linux!

Automatic realtime IRQ priorities using rtirq

, , , ...

UPDATE: I've JUST noticed that there's an RPM at http://www.rncbc.org/jack/ - install and you're away! That man's a genius.

When using audio on Linux, you have to be aware of the the realtime priorities of the system. And even though you may have edited the /etc/security/limits.conf file, the thread priorities of the sound card will not be set.

Rui Nuno Capela [creator of qjackctl and the excellent qtractor] wrote a script to help set the priorities of the most likely IRQs for your system. It didn't require any tweaking; however, when I first tried to use it there were no instructions as to how to apply it. SO...

  1. Download the script from http://www.rncbc.org/jack/ (you'll need to head to the end of the page)
  2. Extract the tar file. For this I used my file browser, PCManFM. No need for the terminal. Yet.
  3. NOW open a terminal.
  4. Become root by typing su and the root password.
  5. Enter cd {path to rtirq script} - this takes you to where the script is.
  6. Then cp rtirq.conf /etc/ - this copies rtirq's config file to /etc/
  7. Then cp rtirq.sh /etc/init.d/rtirq - this copies rtirq.sh to the /etc/init.d/ folder, making it a system script. It then renames it as rtirq
  8. Now enter insserv /etc/init.d/rtirq - this installs the script for the system on startup
  9. Lastly, enter ln -s /etc/init.d/rtirq /sbin/rcrtirq -this turns the script into a command


Now when you enter rcrtirq you'll get

Usage /sbin/rcrtirq {[re]start|stop|reset|status}



You can only use the command as root unfortunately, but it doesn't matter because this script will now start when you switch your computer on - which means you don't have to think about it!

Lime for Linux: a small and esoteric guide

, , , ...

In case you didn't know, I'm a musician and composer. That's my main job (I also work in a bookshop a couple of days a week) and I work in the fields of contemporary music and jazz.

This does not make for a multi-million pound lifestyle. And music can be an expensive profession. I made the switch - fairly painfully, as it happens, but quite successfully in the end - to a Linux system. It was painful because even though there are a lot of resources to generally help with a generic system, you do have to read each bit of help you find the help you need for your specific system. This takes time, which is where (for a new user) Linux is very expensive indeed.

But on the plus side, my time fixing a system so that it works well for me doesn't actually cost me money. As money is the thing in which I'm deficient (I can always find time to do something else!) then Linux is a very good choice for a self-employed musician. More and more distributions are being made with audio applications in mind, and I strongly feel that musicians inputting knowledge to the work would only strengthen it.

That said, there was one piece of software from my old Windows system that I haven't been able to let go of. Lime is a music notation editor that I've used for the last five years. I bought my version at a ridiculously good £45; it's done a lot of good work for me over the years and I highly recommend it, especially if you can touch-type as it gives each pitch a keypress of its own (LIKE A PIANO! unlike most other notation editors, for which you enter a note {a, b, c, &c.} and then enter the sharp or flat as an alteration).

I dallied with the various notation solutions for Linux and realised that

  1. I don't like entering code to write Western notation (Lilypond, CMN). In fact, I think it's weird. We're dealing with the visual medium. It's quicker to write it by hand.
  2. I don't like frontends that don't offer the full range of options that the backend can deliver (Denemo, Rosegarden, Noteedit, Nted - and yes, that's almost all of them).
  3. I don't want to enter two keys for one note (all of them including Musescore which apart from that and the fact that it crashes openSUSE 11 fairly regularly, is very good)
  4. I want total control of the number of lines on a stave (unlike any of them except Musescore - but only after the first measure - and Canorus. Unfortunately, this was the only aspect of Canorus I liked and could use)


So, I headed back to Lime and set about making it work. There exists a Microsoft compatibility application called WINE: it does all the really hard work of getting Lime to run, but the notes didn't display at all. So I re-encoded the fonts so that they would display, and give a small guide to get it to work. The only thing you will need (that I cannot supply) is the Symbol font from Microsoft Windows. But you should be able to pull it off an existing Windows system, like I did. With luck, it'll join the other MS core fonts in time. Who knows?

Anyway, the caveat: I'm using openSUSE 11.0 and Fluxbox. I'm not a programmer. I don't know enough about Linux to help you out in advanced cases. It's working here. I HOPE it works for you.

  1. Copy the Symbol font to the fonts directory of your WINE installation (this may be at /home/(username)/.wine/drive_c/windows/fonts/)
  2. Download and install Lime (it doesn't matter where as long as you know where it is - for this example I'm going to say it's at /home/corey/Lime/)
  3. Download this zip file with the modified fonts and extract it into the Lime directory


Now we need to add Lime to the Fluxbox menu. To do this
  1. Open up /home/(username)/.fluxbox/usermenu in a text editor
  2. Since my path to Lime.exe is at /home/corey/Lime/ I would add

    [exec](Lime) {wine /home/corey/Lime/Lime.exe}

    to the file
  3. Save usermenu. On my version of Fluxbox (1.1.1) this updates the menu automatically so you can see if it works straightaway


To actually hear the output from Lime, you'll need Timidity, which allows you to hear MIDI events through your soundcard. I decided to have Timidity start up when Lime did, through a keypress: I went to /home/corey/.fluxbox/keys using a text editor and added the line

Mod4 F9 :MacroCmd {Exec timidity -iA D} {Exec wine /home/corey/Lime/Lime.exe}



Every time I hold down the Windows key and hit F9, Timidity starts up, then Lime. I'm then ready to write and can hear the stuff I've done.

Lime uses the Alt key to select annotations and chord symbols - this cannot be changed inside the program, and for Fluxbox users the Alt key is normally used to move a window. Luckily Fluxbox allows you to change this behaviour. Open up the keys file again and scroll down to the area that says

# alt + left/right click to move/resize a window
OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}
OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing NearestCorner}



And change Mod1 to Mod4.

It's all very nifty, and didn't take me all that long to do after I'd got the fonts re-encoded. Of course, I'm still waiting for the day that I can happily use an open source notation tool as well as Lime... but until then...
Download Opera, the fastest and most secure browser