SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-06-28 23:34:39

orax
New Member
From: France
Registered: 2013-06-28
Posts: 2

[Kupfer App Launcher] Crunchbang style theme

Hi everybody,

I am new to CrunchBang,  I was seeking around for a new distribution to settle based on Debian (or Ubuntu), Debian himself was okay, but I was also seeking for a Window Manager that I really liked and i found CrunchBang. I used to work on Ubuntu (Unity & Gnome2), Mint (Cinnamon & i3) and OpenSUSE (Gnome3) but i finaly found what I need : Crunchbang.

The only thing that I needed was a better App Launcher and I found Kupfer : nice, clean, and useful.
Also not so ugly (a la Gnome-Do), but the availlable themes were not so CrunchBang friendly, so I decided to make my own and to share it with you.

Preview :  kupfer.png

So the script is :

__kupfer_name__ = _("Crunch Theme")
__kupfer_sources__ = ()
__description__ = _("Use a Crunchbang Style theme")
__version__ = "1.0"
__author__ = "Jean-Philippe 'Orax' Roemer"

import os
import gtk

from kupfer import config
from kupfer import plugin_support

"""
Kupfer's UI can be themed by using the normal GtkRc style language
Theming can change colors and some pre-defined parameters, but
not the layout.

See also Documentation/GTKTheming.rst
      or https://github.com/engla/kupfer/blob/master/Documentation/GTKTheming.rst

For general information about GTK+ styles,
please see http://live.gnome.org/GnomeArt/Tutorials/GtkThemes

"""
CRUNCH_STYLE = """
style "crunch"
{
        ## Main Window
        KupferWindow :: corner-radius = 0
        KupferWindow :: opacity = 90
        KupferWindow :: decorated = 0
        KupferWindow :: border-width = 4

        ## Selected Item in Main Window
        MatchView :: corner-radius = 5
        MatchView :: opacity = 90

        ## Search List
        Search :: list-opacity = 93
        Search :: list-length = 200

        ## bg: background color
        bg[NORMAL] = "#424242"
        bg[SELECTED] = "#353535"
        bg[ACTIVE] = "#222"
        bg[PRELIGHT] = "#222"
        bg[INSENSITIVE] = "#333"

        ## fg: foreground text color
        fg[NORMAL] = "#DDD"
        fg[SELECTED] = "#EEE"
        fg[ACTIVE] = "#EEE"
        fg[PRELIGHT] = "#EEE"
        fg[INSENSITIVE] = "#DDD"

        ## text: text color in input widget and treeview
        text[NORMAL] = "#EEE"
        text[SELECTED] = "#EEE"
        text[ACTIVE] = "#EEE"

        ## base: background color in input widget and treeview
        base[NORMAL] = "#777"
        base[SELECTED] = "#111"
        base[ACTIVE] = "#353535"
}

## The main window is kupfer
widget "kupfer" style "crunch"
widget "kupfer.*" style "crunch"

## The result list is kupfer-list
widget "kupfer-list.*" style "crunch"
"""

all_styles = {
	'default': None,
	'crunch': CRUNCH_STYLE,
}

__kupfer_settings__ = plugin_support.PluginSettings(
		{
			"key": "theme",
			"label": _("Theme:"),
			"type": str,
			"value": 'default',
			"alternatives": all_styles.keys(),
		},
	)

def cache_filename():
	return os.path.join(config.get_cache_home(), __name__)

def re_read_theme():
	## force re-read theme
	## FIXME: re-read on all screens
	settings = gtk.settings_get_default()
	gtk.rc_reparse_all_for_settings(settings, True)

def initialize_plugin(name):
	"""
	Theme changes are only reversible if we add
	and remove gtkrc files.
	"""
	use_theme(all_styles.get(__kupfer_settings__['theme']))
	__kupfer_settings__.connect_settings_changed_cb(on_change_theme)

def on_change_theme(sender, key, value):
	if key == 'theme':
		use_theme(all_styles.get(__kupfer_settings__[key]))

def use_theme(style_str):
	"""
	Use the GTK+ style in @style_str,
	or unset if it is None
	"""
	filename = cache_filename()
	if style_str is None:
		filename = cache_filename()
		gtk.rc_set_default_files([f for f in gtk.rc_get_default_files()
		                          if f != filename])
	else:
		with open(filename, "wb") as rcfile:
			rcfile.write(style_str)
		gtk.rc_add_default_file(filename)
	re_read_theme()

def finalize_plugin(name):
	use_theme(None)
	re_read_theme()
	## remove cache file
	filename = cache_filename()
	assert ("kupfer" in filename)
	try:
		os.unlink(filename)
	except OSError:
		pass

View it online at Launchpad

Download and copy the script or create the file on the Kupfer Plugin directory :

/usr/share/kupfer/kupfer/plugin/

Feel free to tell me what can be changed and what do you think about this theme. smile

Cheers, orax  monkey

PS : Sorry for my English wink

EDIT :
Kupfer is availlable on Debian Stable repo :

sudo apt-get install kupfer

Last edited by orax (2013-06-30 01:29:48)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo