Archive

Posts Tagged ‘Linux’

rsslibnotify – My very first python script

October 28th, 2010 6 comments

UPDATE: I included tante’s comments and extended the program. The config-file now allows you to define the checking interval and will be automatically created if nonexisting.

I noticed that gwibber removed their rss support for some reason. However, it would be really nice to have the option for libnotify to …well… notify you on gnome when there is something new on rss/atom feeds you find important. Since I always wanted to learn python anyway, I hacked together a small script, which does exactly that. Just create a config file in ~/.rsslibnotify with a number of rss/atom feeds separated by newlines and you will be informed every ten minutes via libnotify if there’s something new. (see update above)

feedparser and pynotify need to be installed prior. Btw. feedparser is giving me errors while installing, however seems to be working without a problem.

Of course this script is far from perfect. Keep in mind it’s my first python script and I worked at most one to two hours on it ;).

Available for download here: rsslibnotify.py

#!/usr/bin/python
# coding=utf-8
 
#
#    Copyright 2010 by Daniel Süpke
#
#    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/>.
 
#
# rsslibnotify v0.3
#
 
import pynotify
import feedparser
import time
import os.path
import sys
 
config_file = os.path.expanduser('~/.rsslibnotify')
feeds = []
titles = []
 
try:
    file = open(config_file, 'r')
except:
    file = open(config_file, 'w')
    file.write('# amount of seconds to wait before checking for new items\n')
    file.write('interval 600\n\n')
    file.write('# feeds to check\n')
    file.write('feed https://suepke.net/feed/\n')
    file.write('feed http://rss.golem.de/rss.php?feed\x3dRSS1.0\x26ms\x3drss\n')
 
    print('Config file not found! Created example file at ' + config_file + '. Please edit.')
    sys.exit(0)
 
for line in file.readlines():
    config_line = line.rstrip().partition('#')[0] # Remove \n and comments
 
    if config_line.startswith('feed '):
        feeds.append(config_line.partition('feed ')[2])
    if config_line.startswith('interval '):
        interval = int(config_line.partition('interval ')[2])
 
    titles.append('')
 
file.close()
 
if not feeds:
    print('There were no feeds in your config file at ' + config_file + '. Exiting...')
    sys.exit(0)
 
if not interval:
    print('No check interval has been defined. Assuming ten minutes.')
    interval = 600
 
# Check for new feeds every interval seconds
while True:
    i = 0
 
    for feed in feeds:
        d = feedparser.parse(feed)
 
        # Assume new content if there is a new title
        if d.entries[0].title != titles[i]:
            titles[i] = d.entries[0].title
 
            if pynotify.init('rssnotify'):
                n = pynotify.Notification(d.feed.title, d.entries[0].title)
                n.show()
            else:
                print('there was a problem initializing the pynotify module')
        i += 1
 
    time.sleep(interval)

Enabling Automatic Upgrades for Ubuntu

May 9th, 2009 No comments

Ubuntu allows you to install security updates automatically in the background (under Synaptic -> Repositories -> Updates), but there was only the option Install Security updates without notification, no option for just installing all updates. I searched for a way to automate it and found the solution in launchpad:

Just open /etc/apt/apt.conf.d/50unattended-upgrades and enable all updates, then you can have daily automatic upgrades without notification. No more need to confirm all the same upgrades on different computers again and again, neat!

See also: Linux Hater’s Blog

March 18th, 2009 No comments

Although I am somewhat of the Linux4ever faction, I’d never say that there are not many problems with it (just not as bad as in Windows). In fact, I really hate fundamentalists claiming everything is fine (and everything else bad), regardless of coming from Linux, religion or whatever. Because fundamentalism leads to stagnation, ignorance, and ultimately demise.

Fact is, there are a lot of problems with Linux, as with every complex software/community. And some of them are even specific for Linux and won’t occur in Windows (and vice versa). Yet, saying e.g. ubuntu is all shiny out of pure rejection for Windows is not helping anyone. But, like in every community where people think they are on the “morally correct” side, it attracts a lot of these single-eyed fundamentalists.

This is why I utterly enjoy the Linux Haters’s Blog: It’s flaming the most common problems of Linux all of us encountered in an absolutely ridiculous way, which is not only enjoyable to read, but makes visible the big problems existing within it. Sometimes it just needs someone to absolutely mock your believes or way of thinking, so you can notice: “Hey, something might be going the wrong way”. If you are able to break your habits and read the problems hidden behind this hilarious (and most of the time absolutely funny) flames, you will see that there is truth in it, even if exaggerated – or maybe because it’s so exaggerated. For example, have a look at the articles on Gnome apps (funny as hell) or KDE4 (to the point).

Recommended for every Linux fan, especially for the Linux fundamentalists: The Linux Hater’s Blog

Categories: English, Have a look Tags: ,

Embedding Windows in Linux with VirtualBox

February 10th, 2009 3 comments

I am obviously a big fan of Linux and use it at home as well as in my office. But in both places I still require Windows for two reason:

  • At home I require it for gaming. Wine is ok, but can still be a major pain in the ass with configuration and lesser known games.
  • In the office I am obliged to use Microsoft Office. I prefer LaTeX, but compared to OpenOffice the 2007 version of MsOffice is the big winner in my opinion.  But since working under Windows otherwise is out of question for me (I am way more productive with Linux/Gnome), a dual-boot like I use for gaming is no option.

So, in my office, I use VirtualBox to embed Windows inside my Linux desktop. Formerly I used VMware, which admittedly is more powerful, but provides a less appealing user interface and, at that time, did not provide the seamless mode, which I will make use of. To give an impression, here is a screenshot of my desktop:

Using VirtualBox to embed Windows inside Gnome

Using VirtualBox to embed Windows inside Gnome

I will not go through the installation process, as it’s pretty self-explanatory. But what VirtualBox additionally offers is the aforementioned seamless mode (default combination: Right-CTRL + L), which gives you the taskbar over your normal gnome panel. This is really nice, since it allows easy access and switching between Windows and Linux applications. While Alt-Tab is not used optimally (it only lets you access applications of one OS at a time), you can switch between Windows and Linux applications by pressing Right-CTRL before using Alt-Tab.

Another great feature is embedding any host folder (e.g. your home folder) directly inside the Windows explorer as seen on the screenshot. This is achieved by setting a shared folder in Devices->Shared Folders and then adding a network drive. This is as simple as right-clicking on My Computer (unsure about the name, I only have German Windows 😉 ) and adding the drive. From now it’s possible to modify and share files between host and virtual machine without any hassle.

Also, I configured cups to allow web access to the printers configured in Linux, so the Windows VM could easily print by using these. But I haven’t configured this yet since my last installation, so I cannot give a howto right now 😉 .

I hope you enjoy the progress of free VMs like VirtualBox as much as I do, as it allows Windows apps, that are sadly still required, to be used inside your Linux without a hassle and with nice integration. I hope that Alt-Tab is improved, then the whole thing would feel like a natural part of your Linux desktop. Additionally, VirtualBox now has Direct3D support (which I haven’t tested yet), so maybe one day we will be able to even do gaming inside our Linux distributions without any more need for a dual boot.

Update:

For all this, you need to install the Guest additions. You can find these in the menu devices.