diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiz-manager.py~ | 561 |
1 files changed, 0 insertions, 561 deletions
diff --git a/src/compiz-manager.py~ b/src/compiz-manager.py~ deleted file mode 100644 index 9ef72ed..0000000 --- a/src/compiz-manager.py~ +++ /dev/null @@ -1,561 +0,0 @@ -#!/usr/bin/python -# Author(s): Keeguon -import ConfigParser -import gobject -import pygtk -pygtk.require('2.0') -import gtk -from commands import getoutput -from os import system, popen -from os.path import exists -from subprocess import Popen - -# Defining functions -def installed(app): - global app_is_installed - return app in app_is_installed - -def default_gl_decorator(): - global decorator - if installed('kde-window-decorator') and dcop == 1 and gnome_session == 0: - decorator = 'kde-window-decorator' - if installed('gtk-window-decorator') and gnome_session == 1 and dcop == 0: - decorator = 'gtk-window-decorator' - if installed('emerald') and dcop == gnome_session == 0: - decorator = 'emerald' - if installed('emerald') and dcop == gnome_session == 1: - decorator = 'emerald' - -def fallback_wm(): - configuration = ConfigParser.ConfigParser() - configuration.read(config_file) - if installed('kwin') and dcop == 1 and gnome_session == 0: - configuration.set('window_manager', 'set_active_wm', 'kwin') - if installed('metacity') and gnome_session == 1 and dcop == 0: - configuration.set('window_manager', 'set_active_wm', 'metacity') - -def create_config_file(): - default_config = open(config_file, 'w') - default_config.write('# Config file for compiz-manager (generated with python)\n') - default_config.write('\n') - default_config.write('[window_manager]\n') - default_config.write('set_active_wm = compiz\n') - default_config.write('wm_replace = --replace\n') - default_config.write('\n') - default_config.write('[default_compiz_options]\n') - default_config.write('sm_disable = --sm-disable\n') - default_config.write('\n') - default_config.write('[compiz_options]\n') - default_config.write('fast_filter = \n') - default_config.write('indirect_rendering = --indirect-rendering\n') - default_config.write('loose_binding = --loose-binding\n') - default_config.write('\n') - default_config.write('[compiz_backend]\n') - default_config.write('set_backend = ccp\n') - default_config.write('\n') - default_config.write('[decorator]\n') - default_config.write('set_active_decorator = ' + decorator + '\n') - default_config.write('decorator_replace= --replace') - default_config.close() - -def activate_config_ini(): - # Retrieve configuration from the INI file - configuration = ConfigParser.ConfigParser() - configuration.read(config_file) - # Window Manager - active_wm = configuration.get('window_manager', 'set_active_wm') - if active_wm == 'compiz': - # Env Variables - env_variables = getoutput('compiz -r env') - # Compiz Options - wm_replace = configuration.get('window_manager', 'wm_replace') - sm_disable = configuration.get('default_compiz_options', 'sm_disable') - fast_filter = configuration.get('compiz_options', 'fast_filter') - indirect_rendering = configuration.get('compiz_options', 'indirect_rendering') - loose_binding = configuration.get('compiz_options', 'loose_binding') - backend = configuration.get('compiz_backend', 'set_backend') - # GL Decorator - set_active_decorator = configuration.get('decorator', 'set_active_decorator') - decorator_replace = configuration.get('decorator', 'decorator_replace') - # Start Compiz WM - Popen(['killall' , 'compiz.real' , 'metacity' , 'kwin']) - system('export' + env_variables) - Popen(['compiz.real' , wm_replace , sm_disable , fast_filter , indirect_rendering , loose_binding , backend]) - # Start GL Decorator - Popen(['killall' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald']) - Popen([set_active_decorator , decorator_replace]) - if active_wm == 'metacity': - wm_replace = configuration.get('window_manager', 'wm_replace') - # Start Metacity WM - Popen(['killall' , 'compiz.real' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen(['metacity' , wm_replace]) - if active_wm == 'kwin': - wm_replace = configuration.get('window_manager', 'wm_replace') - # Start Kwin WM - Popen(['killall' , 'compiz.real' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen(['kwin' , wm_replace]) - -def activate_compiz_manager(): - if installed('compiz.real'): - activate_config_ini() - else: - fallback_wm() - activate_config_ini() - -# Compiz-Manager Menu Functions -def popup_menu(widget, button, time, data = None): - if button == 3: - if data: - data.show_all() - data.popup(None, None, None, 3, time) - pass - -def configure_menu_activate(widget): - gobject.spawn_async(['ccsm'], flags=gobject.SPAWN_SEARCH_PATH) - -def etm_menu_activate(widget): - Popen(['emerald-theme-manager']) - -def start_wm(widget): - if installed('compiz'): - activate_config_ini() - else: - fallback_wm() - activate_config_ini() - -def compiz_menu_activate(widget): - # Env Variables - env_variables = getoutput('compiz -r env') - # Set compiz wm - configuration.set('window_manager', 'set_active_wm', 'compiz') - configuration.write(open(config_file, 'w')) - # Get compiz wm - set_active_wm = configuration.get('window_manager', 'set_active_wm') - wm_replace = configuration.get('window_manager', 'wm_replace') - # Get compiz options - sm_disable = configuration.get('default_compiz_options', 'sm_disable') - fast_filter = configuration.get('compiz_options', 'fast_filter') - indirect_rendering = configuration.get('compiz_options', 'indirect_rendering') - loose_binding = configuration.get('compiz_options', 'loose_binding') - backend = configuration.get('compiz_backend', 'set_backend') - # Get gl decorator - set_active_decorator = configuration.get('decorator', 'set_active_decorator') - decorator_replace = configuration.get('decorator', 'decorator_replace') - # Run compiz - Popen(['killall' , 'compiz.real' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - system('export' + env_variables) - Popen(['compiz.real' , wm_replace , sm_disable , fast_filter , indirect_rendering , loose_binding , backend]) - Popen([set_active_decorator , decorator_replace]) - -def kwin_menu_activate(widget): - # Set kwin wm - configuration.set('window_manager', 'set_active_wm', 'kwin') - configuration.write(open(config_file, 'w')) - # Get kwin wm - set_active_wm = configuration.get('window_manager', 'set_active_wm') - wm_replace = configuration.get('window_manager', 'wm_replace') - # Run kwin - Popen(['killall' , 'compiz.real' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen([set_active_wm , wm_replace]) - -def metacity_menu_activate(widget): - # Set metacity wm - configuration.set('window_manager', 'set_active_wm', 'metacity') - configuration.write(open(config_file, 'w')) - # Get metacity wm - set_active_wm = configuration.get('window_manager', 'set_active_wm') - wm_replace = configuration.get('window_manager', 'wm_replace') - # Run metacity - Popen(['killall' , 'compiz.real' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen([set_active_wm , wm_replace]) - -def backend_ccp_activate(widget): - # Set ccp backend - configuration.set('compiz_backend', 'set_backend', 'ccp') - configuration.write(open(config_file, 'w')) - -def backend_gconf_activate(widget): - configuration.set('compiz_backend', 'set_backend', 'gconf') - configuration.write(open(config_file, 'w')) - -def option_ff_activate(widget): - # Set/Unset ff option - if option_ff.get_active() == True: - configuration.set('compiz_options', 'fast_filter', '--fast-filter') - configuration.write(open(config_file, 'w')) - else: - configuration.set('compiz_options', 'fast_filter', '') - configuration.write(open(config_file, 'w')) - -def option_ir_activate(widget): - # Set/Unset ir option - if option_ir.get_active() == True: - configuration.set('compiz_options', 'indirect_rendering', '--indirect-rendering') - configuration.write(open(config_file, 'w')) - else: - configuration.set('compiz_options', 'indirect_rendering', '') - configuration.write(open(config_file, 'w')) - -def option_lb_activate(widget): - # Set/Unset lb option - if option_lb.get_active() == True: - configuration.set('compiz_options', 'loose_binding', '--loose-binding') - configuration.write(open(config_file, 'w')) - else: - configuration.set('compiz_options', 'loose_binding', '') - configuration.write(open(config_file, 'w')) - -def start_decorator(widget): - # Get gl decorator - set_active_decorator = configuration.get('decorator', 'set_active_decorator') - decorator_replace = configuration.get('decorator', 'decorator_replace') - # Run gl decorator - Popen(['killall' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen([set_active_decorator , decorator_replace]) - -def emerald_menu_activate(widget): - # Set emerald decorator - configuration.set('decorator', 'set_active_decorator', 'emerald') - configuration.write(open(config_file, 'w')) - # Get emerald decorator - set_active_decorator = configuration.get('decorator', 'set_active_decorator') - decorator_replace = configuration.get('decorator', 'decorator_replace') - # Run emerald - Popen(['killall' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen([set_active_decorator , decorator_replace]) - -def kwd_menu_activate(widget): - # Set kwd decorator - configuration.set('decorator', 'set_active_decorator', 'kde-window-decorator') - configuration.write(open(config_file, 'w')) - # Get kwd decorator - set_active_decorator = configuration.get('decorator', 'set_active_decorator') - decorator_replace = configuration.get('decorator', 'decorator_replace') - # Run kwd - Popen(['killall' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen([set_active_decorator , decorator_replace]) - -def gwd_menu_activate(widget): - # Set gwd decorator - configuration.set('decorator', 'set_active_decorator', 'gtk-window-decorator') - configuration.write(open(config_file, 'w')) - # Get gwd decorator - set_active_decorator = configuration.get('decorator', 'set_active_decorator') - decorator_replace = configuration.get('decorator', 'decorator_replace') - # Run gwd - Popen(['killall' , 'gtk-window-decorator' , 'kde-window-decorator' , 'emerald' , 'metacity' , 'kwin']) - Popen([set_active_decorator , decorator_replace]) - -def about_window(widget): - # About Window - about_window = gtk.Window(type=gtk.WINDOW_TOPLEVEL) - about_window.set_title('About - Compiz Manager') - about_window.set_default_size(400, 227) - about_window.set_position(gtk.WIN_POS_CENTER) - - # Vbox - vbox = gtk.VBox(False, 0) - about_window.add(vbox) - - # Compiz Logo - compiz_logo = gtk.Image() - compiz_logo.set_from_file(pixmap_dir + 'about.png') - - # Title Text - title_text = gtk.Label() - title_text.set_markup( - '<span size="xx-large"><b>Compiz Manager v0.6</b></span>' - ) - title_text.set_justify(gtk.JUSTIFY_CENTER) - - # Undertitle Text - undertitle_text = gtk.Label() - undertitle_text.set_markup( - 'User friendly launcher for Compiz/CompComm\n' - ) - undertitle_text.set_justify(gtk.JUSTIFY_CENTER) - - # Author Text - author_text = gtk.Label() - author_text.set_markup( - '<small>Copyleft - 2007 - F. Bellanger</small>' - ) - undertitle_text.set_justify(gtk.JUSTIFY_CENTER) - - # Buttons - hbox_buttons = gtk.HBox(False, 0) - - credits_button = gtk.Button(' _Credits', use_underline=True) - credits_image = gtk.Image() - credits_image.set_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_BUTTON) - credits_button.set_image(credits_image) - credits_button.connect("clicked", credits_window) - quit_button = gtk.Button(stock=gtk.STOCK_CLOSE) - quit_button.connect("clicked", lambda x: about_window.destroy()) - quit_alignment = gtk.Alignment(1, 0, 0, 0) - quit_alignment.add(quit_button) - - hbox_buttons.pack_start(credits_button, False, False, 5) - hbox_buttons.pack_start(quit_alignment, True, True, 5) - - # Adding elements to the Vbox - vbox.pack_start(compiz_logo, False, False, 5) - vbox.pack_start(title_text, False, False, 5) - vbox.pack_start(undertitle_text, False, False, 5) - vbox.pack_start(author_text, False, False, 5) - vbox.pack_start(hbox_buttons, False, False, 5) - - about_window.show_all() - -def credits_window(widget): - # Credits Window - credits_window = gtk.Window(type=gtk.WINDOW_TOPLEVEL) - credits_window.set_title('Credits - Compiz Manager') - credits_window.set_default_size(350, 275) - credits_window.set_position(gtk.WIN_POS_CENTER) - - # Vbox for Credits Window - vbox_credits = gtk.VBox(False, 0) - credits_window.add(vbox_credits) - - # Written by tab - writtenby_frame = gtk.Frame() - writtenby_frame.set_shadow_type(gtk.SHADOW_OUT) - writtenby_textarea = gtk.TextView() - writtenby_textarea.set_editable(False) - writtenby_textarea.set_size_request(0, 185) - writtenby_buffer = writtenby_textarea.get_buffer() - writtenby_buffer.set_text('Felix Bellanger <keeguon@gmail.com>') - activate_scroll = gtk.ScrolledWindow() - activate_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - activate_scroll.add(writtenby_textarea) - writtenby_frame.add(activate_scroll) - - # Set Tab box - writtenby_label = gtk.Label('Written by') - tab_box = gtk.Notebook() - tab_box.append_page(writtenby_frame, tab_label=writtenby_label) - - # Close button - close_button = gtk.Button(stock=gtk.STOCK_CLOSE) - close_button.connect("clicked", lambda x: credits_window.destroy()) - close_alignment = gtk.Alignment(1, 0, 0, 0) - close_alignment.add(close_button) - - # Append elements to Credits Window via Vbox - vbox_credits.pack_start(tab_box, False, True, 10) - vbox_credits.pack_start(close_alignment, False, True, 0) - - # Show Credits Window - credits_window.show_all() - -def quit_menu_activate(widget): - gtk.main_quit() - -# Read list of running processes -processes = popen('ps -A').readlines() - -# Check wether GNOME or KDE running -dcop = gnome_session = 0 -for line in processes: - if 'dcop' in line.strip(): - dcop = 1 - gnome_session = 0 - if 'gnome-session' in line.strip(): - dcop = 0 - gnome_session = 1 - -# Get installed application -app_is_installed = [] -apps = ('compiz.real', 'ccs-settings' , 'gtk-window-decorator', 'kde-window-decorator', 'emerald' , 'metacity' , 'kwin') -for application in apps: - if system("which " + application) == 0: - app_is_installed.append(application) - -# Get default GL Decorator -default_gl_decorator() - -# Variables -user = getoutput("whoami") -home_directory = '/home/' + user + '/.compiz-manager' -config_file = home_directory + '/config.ini' -pixmap_dir = '/usr/share/pixmaps/compiz-manager/' - -# Home directory related stuffs -if exists(home_directory) == False: - # Create home directory - Popen(['mkdir /home/' + user + '/.compiz-manager']) - # Create and Write the default config_file - create_config_file() -if exists(home_directory) == True and exists(config_file) == False: - # Create and Write the default config_file - create_config_file() - -# Retrieve config from INI File -configuration = ConfigParser.ConfigParser() -configuration.read(config_file) -# WM -set_active_wm = configuration.get('window_manager', 'set_active_wm') -# Decorator -set_active_decorator = configuration.get('decorator', 'set_active_decorator') -# Backend -backend = configuration.get('compiz_backend', 'set_backend') -# Options -fast_filter = configuration.get('compiz_options', 'fast_filter') -indirect_rendering = configuration.get('compiz_options', 'indirect_rendering') -loose_binding = configuration.get('compiz_options', 'loose_binding') - -# Window Manager -wm_menu = gtk.Menu() -if installed('compiz.real'): - compiz_wm = gtk.RadioMenuItem(label=" Compiz") - compiz_wm.connect("activate", compiz_menu_activate) - if set_active_wm == 'compiz': - compiz_wm.set_active(True) - wm_menu.append(compiz_wm) -if installed('kwin'): - kwin_wm = gtk.RadioMenuItem(label=" Kwin") - kwin_wm.set_group(compiz_wm) - kwin_wm.connect("activate", kwin_menu_activate) - if set_active_wm == 'kwin': - kwin_wm.set_active(True) - wm_menu.append(kwin_wm) -if installed('metacity'): - metacity_wm = gtk.RadioMenuItem(label=" Metacity") - metacity_wm.set_group(compiz_wm) - metacity_wm.connect("activate", metacity_menu_activate) - if set_active_wm == 'metacity': - metacity_wm.set_active(True) - wm_menu.append(metacity_wm) - -# Compiz Backend -backend_menu = gtk.Menu() -backend_ccp = gtk.RadioMenuItem(label=" CCP Backend") -backend_ccp.connect("activate", backend_ccp_activate) -if backend == 'ccp': - backend_ccp.set_active(True) -backend_menu.append(backend_ccp) -backend_gconf = gtk.RadioMenuItem(label=" Gconf Backend") -backend_gconf.connect("activate", backend_gconf_activate) -if backend == 'gconf': - backend_gconf.set_active(True) -backend_menu.append(backend_gconf) - -# Compiz Options -options_menu = gtk.Menu() -option_ff = gtk.CheckMenuItem(label=" Fast Filter") -option_ff.connect("activate", option_ff_activate) -if fast_filter == '--fast-filter': - option_ff.set_active(True) -options_menu.append(option_ff) -option_ir = gtk.CheckMenuItem(label=" Indirect Rendering") -option_ir.connect("activate", option_ir_activate) -if indirect_rendering == '--indirect-rendering': - option_ir.set_active(True) -options_menu.append(option_ir) -option_lb = gtk.CheckMenuItem(label=" Loose Binding") -option_lb.connect("activate", option_lb_activate) -if loose_binding == '--loose-binding': - option_lb.set_active(True) -options_menu.append(option_lb) - -# Window Decorator -decorator_menu = gtk.Menu() -if installed('emerald'): - emerald_decorator = gtk.RadioMenuItem(label=" Emerald") - emerald_decorator.connect("activate", emerald_menu_activate) - if set_active_decorator == 'emerald': - emerald_decorator.set_active(True) - decorator_menu.append(emerald_decorator) -if installed('kde-window-decorator'): - kwd_decorator = gtk.RadioMenuItem(label=" KDE Window Decorator") - kwd_decorator.set_group(emerald_decorator) - kwd_decorator.connect("activate", kwd_menu_activate) - if set_active_decorator == 'kde-window-decorator': - kwd_decorator.set_active(True) - decorator_menu.append(kwd_decorator) -if installed('gtk-window-decorator'): - gwd_decorator = gtk.RadioMenuItem(label=" GTK Window Decorator") - gwd_decorator.set_group(emerald_decorator) - gwd_decorator.connect("activate", gwd_menu_activate) - if set_active_decorator == 'gtk-window-decorator': - gwd_decorator.set_active(True) - decorator_menu.append(gwd_decorator) - -# Compiz-Manager Tray Menu -menu = gtk.Menu() -item = gtk.ImageMenuItem(stock_id=gtk.STOCK_PREFERENCES) -item.connect("activate", configure_menu_activate) -menu.append(item) -item = gtk.ImageMenuItem('Emerald Theme Manager') -if installed('emerald'): - item.set_sensitive(True) -else: - item.set_sensitive(False) -item.connect("activate", etm_menu_activate) -img_etm = gtk.Image() -img_etm.set_from_icon_name("emerald-theme-manager-icon", gtk.ICON_SIZE_MENU) -item.set_image(img_etm) -menu.append(item) -item = gtk.SeparatorMenuItem() -menu.append(item) -# Window Manager Options -item = gtk.ImageMenuItem("Start/Reload Window Manager") -item.connect("activate", start_wm) -img_refresh = gtk.Image() -img_refresh.set_from_stock("gtk-refresh", gtk.ICON_SIZE_MENU) -item.set_image(img_refresh) -menu.append(item) -item = gtk.ImageMenuItem("Select Window Manager") -gtk.MenuItem.set_submenu(item, wm_menu) -img_wm = gtk.Image() -img_wm.set_from_file(pixmap_dir + 'wm-select.png') -item.set_image(img_wm) -menu.append(item) -item = gtk.MenuItem("Compiz Backend") -gtk.MenuItem.set_submenu(item, backend_menu) -menu.append(item) -item = gtk.ImageMenuItem("Compiz Options") -gtk.MenuItem.set_submenu(item, options_menu) -img_options = gtk.Image() -img_options.set_from_stock("gtk-properties", gtk.ICON_SIZE_MENU) -item.set_image(img_options) -menu.append(item) -item = gtk.SeparatorMenuItem() -menu.append(item) -# Window Decorator Options -item = gtk.ImageMenuItem("Start/Reload Decorator") -item.connect("activate", start_decorator) -img_refresh = gtk.Image() -img_refresh.set_from_stock("gtk-refresh", gtk.ICON_SIZE_MENU) -item.set_image(img_refresh) -menu.append(item) -item = gtk.ImageMenuItem("Select Window Decorator") -gtk.MenuItem.set_submenu(item, decorator_menu) -img_wd = gtk.Image() -img_wd.set_from_file(pixmap_dir + 'wd-select.png') -item.set_image(img_wd) -menu.append(item) -item = gtk.SeparatorMenuItem() -menu.append(item) -# Compiz-Manager About and Quit -item = gtk.ImageMenuItem(stock_id=gtk.STOCK_ABOUT) -item.connect("activate", about_window) -menu.append(item) -item = gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT) -item.connect("activate", quit_menu_activate) -menu.append(item) -menu.show_all() - -# Compiz-Manager Tray Icon -pixbuf = gtk.gdk.pixbuf_new_from_file(pixmap_dir + 'tray-icon.svg') -tray = gtk.StatusIcon() -tray.set_from_pixbuf(pixbuf) -tray.set_tooltip("Compiz Manager") -tray.connect("popup-menu", popup_menu, menu) - -# Start Compiz -activate_compiz_manager() - -# Compiz-Manager Main -gtk.main() |