Launching Newsbeuter from the Dock

There are plenty of RSS readers out there, but I just found one that fits my minimalistic CLI needs like a glove: Newsbeuter. It’s available for OS X via Homebrew (as well as multiple flavours of Linux).

Installing Newsbeuter wasn’t quite as straightforward as it could’ve been, especially since I wanted to be able to launch it into iTerm from the Dock, so I decided to document the process here.

  1. Install Newsbeuter via Homebrew
    $ brew install newsbeuter
  2. Once successfully installed, try launching the program.
    If you get an error message saying “setlocale failed: No such file or directory“, you need to set your LANG environment variable. Add this in your ~/.bash_profile and try again:
    export LANG="en_US.UTF-8"
  3. If Newsbeuter is happy with the locale settings, you’ll be greeted with an error message saying “Error: no URLs configured” along with a whole lot of other stuff and usage instructions. Add RSS URLs to your urls-file as instructed.
  4. You should now have a regular Newsbeuter installation up and running. Next, we want to be able to launch it from the Dock.

    Copy and paste this into your favourite text editor, and save it at "~/scripts/launch_newsbeuter.sh".

    #!/bin/bash
    # Script 2/2 of "Launching Newsbeuter from the Dock": "launch_newsbeuter.sh"
    # Requires "newsbeuter.app" to work.
    # See http://blog.ampli.fi/launching-newsbeuter-from-the-dock
    
    # Make sure we don't attempt to open multiple instances of Newsbeuter.
    killall newsbeuter
    
    # Remove the lock file in case we have killed the terminal with the previous
    # instance of Newsbeuter, which would leave the pid file orphaned, preventing
    # us from running a new instance.
    rm -f ~/.newsbeuter/cache.db.lock
    
    # Run Newsbeuter
    /usr/local/bin/newsbeuter
    
    
  5. Add execution rights:
    $ cd ~/scripts/
    $ chmod u+x launch_newsbeuter.sh
  6. Launch AppleScript editor, and copy and paste this into it:
    # Script 1/2 of "Launching Newsbeuter from the Dock": "newsbeuter.app"
    # Requires "launch_newsbeuter.sh" to work.
    # See http://blog.ampli.fi/launching-newsbeuter-from-the-dock
    #
    # This AppleScript was copied from
    # http://damonparker.org/blog/2005/09/14/iterm-tricks/
    tell application "iTerm"
    	make new terminal
    	tell the current terminal
    		activate current session
    		launch session "Default Session"
    		tell the last session
    			# Run the shell script that launches the terminal window that launches
    			# Newsbeuter.
    			write text "~/scripts/launch_newsbeuter.sh"
    		end tell
    	end tell
    end tell
    
  7. Save the AppleScript anywhere as newsbeuter.app by selecting “File format: Application” in the save-dialogue.
  8. Drag your new application in your Dock, and launch!

Since I wrote the instructions after I’d finished the installation myself, I may have omitted some steps. As usual, comments are welcome.

There is in fact one problem with the setup: If iTerm is running with no open terminal windows, the script crashes with an error message saying 'Can't get «class Ctrm» of application "iTerm".' If anyone knows how to fix that, please leave a comment. I suspect it just needs an extra check for creating a new window if there isn’t one, but it’s already way too late look it up right now.

Published
Categorized as IT

Leave a comment

Your email address will not be published. Required fields are marked *