Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ironhide-indicator bug #44

Open
Rasive opened this Issue · 3 comments

3 participants

@Rasive

The indicator crashes with the following message when I click on 'Configure Apps'

Traceback (most recent call last):
File "/usr/bin/ironhide-indicator", line 169, in app_configure
Applications_settings(file_set=file_set)
File "/usr/share/ironhide-ui/app/AppSettings.py", line 121, in init
self.build_app_list()
File "/usr/share/ironhide-ui/app/AppSettings.py", line 220, in build_app_list
for app_info in self.file_set.get_apps_info():
File "/usr/share/ironhide-ui/app/DesktopFile.py", line 84, in get_apps_info
app_config = desktop_file.get_app_config()
File "/usr/share/ironhide-ui/app/DesktopFile.py", line 171, in get_app_config
self.app_exec= self.config.get('Desktop Entry','Exec')
File "/usr/lib/python2.7/ConfigParser.py", line 610, in get
raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'Exec' in section: 'Desktop Entry'

I am running Ubuntu 11.04

@rockorequin

There's an ironhide indicator now? So there is! How cool is that!

Mine crashes with the same error if I try and configure anything.

Also mine crashes when I run optirun. I get this message:

(ironhide-indicator:5134): libnotify-WARNING **: you must call notify_init() before showing
**
libnotify:ERROR:notification.c:568:notify_notification_show: code should not be reached
@icb410

I got the configuration dialog to work by removing "examples.desktop" from my home directory

@icb410

Tweaked the ironhide-indicator code a bit. Don't know how to submit this to the author, so I'm pasting below. I think something was screwed up with a function definition notify_state(). I fixed it and added a pynotify.init() call under the init function. I also fixed some spacing/tab indentation issues. This seems to work now, just copy paste into a new file called "ironhide_indicator" and move to /usr/bin/ (you may want to backup the existing copy there).

#!/usr/bin/python
# -*- coding: utf-8 -*-
### BEGIN LICENSE
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <davy.renaud@laposte.net> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return Davy Renaud (glyptostroboides)
# ----------------------------------------------------------------------------
#

#    This file is part of ironhide-ui.
#
#    ironhide-ui 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.
#
#    ironhide-ui 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 ironhide-ui.  If not, see <http://www.gnu.org/licenses/>.
#
### END LICENSE

#UI MODULE
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import appindicator
import pynotify

#SYSTEM MODULE
import os
import subprocess

###ORIGINAL CLASS
import app.Config
from app.AppSettings import Applications_settings, IconSet
from app.DesktopFile import DesktopFile, DesktopFileSet

class IronhideIndicator():
#TODO There must be a better way to get the icon than
    def notify_state(self,title,msg,icon_name):
        self.notification= pynotify.Notification(title, msg, IconSet().get_uri(icon_name,48))  #fixed tab indentation to space
        self.notification.set_urgency(pynotify.URGENCY_CRITICAL)
            #self.notification.set_timeout(pynotify.EXPIRES_NEVER) ######   NICE TO SHOW A MESSAGE SIMPLY
        #FIXME The notification is to slow and this doesn't work
            #self.notification.set_timeout(1000)
        self.notification.show()

###INITIALIZATION OF INDICATOR AND MENU
    def __init__(self):
        #TODO Choose the best category for the indicator : appindicator.CATEGORY_APPLICATION_STATUS or appindicator.CATEGORY_SYSTEM_SERVICES
        self.ind = appindicator.Indicator ("ironhide-indicator", "ironhide-indicator", appindicator.CATEGORY_HARDWARE)
        self.ind.set_status (appindicator.STATUS_ACTIVE)
        self.ind.set_icon_theme_path(app.Config.icon_file_directory)
        #TODO The icons style and accesibility must be enhanced : see icons/test directory
        self.ind.set_icon(app.Config.icon_file_directory + "ironhide-indicator.svg",'Ironhide is unactive')
        self.ind.set_attention_icon (app.Config.icon_file_directory + "ironhide-indicator-active.svg",'Ironhide is active')
        self.card_state=False
        self.build_menu()
        self.menu.show()
        self.ind.set_menu(self.menu)
        pynotify.init("ironhide_indicator")
    def quit(self, widget, data=None):
        gtk.main_quit()

    def build_menu(self):
        self.menu = gtk.Menu()
        self.switch = gtk.CheckMenuItem()
        self.initial_state_checker()
        self.switch.set_sensitive(False)
        self.menu.append(self.switch)

        self.build_menu_separator()

        self.prefered_app_submenu = gtk.MenuItem("Preferred Apps")
        self.update_menu()
        self.prefered_app_submenu.connect('activate', self.update_menu)
        self.menu.append(self.prefered_app_submenu)

        item2 = gtk.MenuItem("Configure Apps")
        item2.connect("activate", self.app_configure)
        self.menu.append(item2)

    #TODO An UI to configure Ironhide would be nice

         #item3 = gtk.MenuItem("Configure Ironhide")
        #item3.show()
        #self.menu.append(item3)

        self.build_menu_separator()

        quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        quit.connect("activate", self.quit)
        self.menu.append(quit)

        self.menu.show_all()

    def build_menu_separator(self):
        separator = gtk.SeparatorMenuItem()
        separator.show()
        self.menu.append(separator)

#FUNCTION TO GET THE MENU FROM THE CONFIG FILE
    def update_menu(self, widget=None):    
        self.pref_menu=gtk.Menu()
        subitem = gtk.MenuItem("Glxgears")
        subitem.connect("activate", self.call_app, ['optirun', 'glxgears'])
        subitem.show()
        self.pref_menu.append(subitem)
        file_set.get_configured_from_cfg()
        for file_name in file_set.configured_set:
            [Name, File_name, Categorie, Icon_name]  = DesktopFile(file_name).get_app_info()
            subitem = gtk.MenuItem(label=Name)
            #TODO : Discuss about style : is an icon needed for this simple shortcut
            #subitem = gtk.ImageMenuItem()
            #subitem.set_image(gtk.image_new_from_pixbuf(IconSet().get_pixbuf(Icon_name,icon_size=gtk.ICON_SIZE_MENU)))
            #subitem.set_label(Name)
            subitem.connect("activate", self.call_app, DesktopFile(file_name).get_exec_list())
            subitem.show()
            self.pref_menu.append(subitem)
        self.pref_menu.show()
        self.prefered_app_submenu.set_submenu(self.pref_menu)


    def initial_state_checker(self):
        if self.attention_state_condition(): self.set_attention_state(notify=False)
        else : self.set_active_state(notify=False)

    def state_checker(self):
        if self.attention_state_condition():
            if self.card_state == False : self.set_attention_state()
        elif self.card_state == True: self.set_active_state()    
        return True

    def attention_state_condition(self):
        stdout_handle = os.popen("cat /etc/default/ironhide |grep VGL_DISPLAY |cut -f2 -d:", "r")
        vgl_display = stdout_handle.read().rstrip("\n")
        vgl_display = "/tmp/.X%s-lock" % vgl_display
        if  os.path.exists(vgl_display): return True
        else: return False

    def set_attention_state(self, notify=True):
        self.ind.set_status(appindicator.STATUS_ATTENTION)
        self.card_state = True
        if notify == True: self.notify_state("Discrete card : ON", "Discrete graphic card is powered on", "ironhide-indicator-active")
        self.switch.set_label("Discrete card : ON")
        self.switch.set_active(True)

    def set_active_state(self, notify=True):
        self.ind.set_status(appindicator.STATUS_ACTIVE)
        self.card_state = False
        if notify == True: self.notify_state("Discrete card : OFF", "Discrete graphic card is powered off", "ironhide-indicator")
        self.switch.set_label("Discrete card : OFF")
        self.switch.set_active(False)

    def app_configure(self,widget):
        Applications_settings(file_set=file_set)

    def call_app(self, widget, app_exec):
    #FIXME There is a problem when closing the launched app and when the indicator has been closed: the indicator is still running : What a daemon!!
        subprocess.Popen(app_exec,shell=False)

    def about_box(self, widget, data=None):
        dialog = gtk.MessageDialog(None, type=gtk.MESSAGE_INFO,buttons=gtk.BUTTONS_NONE,message_format="Preferences/About")
        dialog.format_secondary_text("This is Optimus by mrs_sheep. \n It is based on ironhide by MrMEEE. \n The configuration can (by now) only be set thorugh the config file!")
        dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        dialog.run()
        dialog.destroy()


    def main(self):
        self.state_checker()
        #FIXME It would be nice to avoid this loop : Maybe by using a signal emitted by the system
        #gtk.timeout_add(1000,self.state_checker)
        gobject.timeout_add_seconds(2, self.state_checker)
        gtk.main()

if __name__ == "__main__":

    file_set=DesktopFileSet()
    indicator = IronhideIndicator()
    indicator.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.