Updated 2016-05-30 13:01:06 by JayBy

JayBy 2016-05-30

TkStyles is a theme switcher to handle different GUI libraries on Linux for a uniform look.

You can select a gtk+ theme from the list and see immediatly how the theme looks and save it, if you like it. On the right there are example widgets.

At the moment it uses the GTK+2 themes and can save the colors into the .Xresources and into gtk-3.0/gtk.css. This program is based on the xtk::theme and defColor packages and uses only the default colors and font, not 'borderwidth' or other settings.

Inside is a procedure to read user-defined scripts for common settings (see 'Modules').

Download  edit

   Version 0.2: [TkStyles-0.2.kit]

ToDo  edit

  • Work with qt/kde themes.
  • Create your own themes.
  • Saving ttk::themes as gtk/qt themes.

Usage  edit

SYNOPSIS

tkstyles

tkstyles -gui

tkstyles -t | -theme <Lib>:<Theme>

OPTIONS

Without options the current settings and themes are listed.
-gui
Start the GUI, other options will be ignored.
-t | -theme <Library>:<ThemeName>
A colon separated list with GUI library and theme name. Use it like tkstyles -t gtk2:default for the default gtk2 default theme.

Modules  edit

The modules are user-defined scripts, which will be read of a builtin procedure. You can define commands for the configuration of special programs, like fvwm2, which doesn't read X11 or GTK+ colors. The scripts must be in the system (/etc/tkstyles) or user (HOME/.config/tkstyles) directory with a prefix 'save'. TkStyles provides a 'Color' array to use in the scripts (see xtk::theme).

Example $env(HOME)/.config/tkstyles/saveFvwm.tcl:
#------------------------------------------------------------------------------
#                        Fvwm Rc
#------------------------------------------------------------------------------

set RcFile        [file join $::env(HOME) .fvwm .fvwm2rc]
# Read lines and change values
set RId        [open $RcFile r]
set RcData        ""
foreach Line [split [read $RId] \n] {
    if {[regexp {^[ \t]*Colorset[ \t]*([0-9]+)[ \t]} $Line -> CS]} {
        switch $CS {
            0 {
                lassign [::defColor::tint $Color(Standard,Normal,Back)] L D
                lappend RcData "Colorset 0 bg $Color(Standard,Normal,Back), fg $Color(Standard,Normal,Fore), hi $L, sh $D # Global"
            }
            1 {
                lassign [::defColor::tint $Color(Standard,Normal,Back)] L D
                lappend RcData "Colorset 1 bg $Color(Standard,Normal,Back), fg $Color(Standard,Normal,Fore), hi $L, sh $D # Standard,Normal"
            }
            2 {
                lassign [::defColor::tint $Color(Standard,Select,Back)] L D
                lappend RcData "Colorset 2 bg $Color(Standard,Select,Back), fg $Color(Standard,Select,Fore), hi $L, sh $D # Standard,Select"
            }
            3 {
                lassign [::defColor::tint $Color(Standard,Highlight,Back)] L D
                lappend RcData "Colorset 3 bg $Color(Standard,Highlight,Back), fg $Color(Standard,Highlight,Fore), hi $L, sh $D # Standard,Active"
            }
            4 {
                lassign [::defColor::tint $Color(Standard,Active,Back)] L D
                lappend RcData "Colorset 4 bg $Color(Standard,Active,Back), fg $Color(Standard,Active,Fore), hi $L, sh $D # Standard,Prelight"
            }
            5 {
                lassign [::defColor::tint $Color(Standard,Disabled,Back)] L D
                lappend RcData "Colorset 5 bg $Color(Standard,Disabled,Back), fg $Color(Standard,Disabled,Fore), hi $L, sh $D # Standard,Disabled"
            }
            6 {
                lassign [::defColor::tint $Color(Input,Normal,Back)] L D
                lappend RcData "Colorset 6 bg $Color(Input,Normal,Back), fg $Color(Input,Normal,Fore), hi $L, sh $D # Input,Normal"
            }
            7 {
                lassign [::defColor::tint $Color(Input,Select,Back)] L D
                lappend RcData "Colorset 7 bg $Color(Input,Select,Back), fg $Color(Input,Select,Fore), hi $L, sh $D # Input,Select"
            }
            8 {
                lassign [::defColor::tint $Color(Input,Highlight,Back)] L D
                lappend RcData "Colorset 8 bg $Color(Input,Highlight,Back), fg $Color(Input,Highlight,Fore), hi $L, sh $D # Input,Active"
            }
            9 {
                lassign [::defColor::tint $Color(Input,Active,Back)] L D
                lappend RcData "Colorset 9 bg $Color(Input,Active,Back), fg $Color(Input,Active,Fore), hi $L, sh $D # Input,Prelight"
            }
            10 {
                lassign [::defColor::tint $Color(Input,Disabled,Back)] L D
                lappend RcData "Colorset 10 bg $Color(Input,Disabled,Back), fg $Color(Input,Disabled,Fore), hi $L, sh $D # Input,Disabled"
            }
            default {
                lappend RcData        $Line
            }
        }
    } else {
        lappend RcData        $Line
    }
}
close $RId
# Correction for empty lines at end
while {1} {
        if {[lindex $RcData end] == ""} {
                set RcData        [lreplace $RcData end end]
                continue
        } else {
                break
        }
}
# Write to file
set RId        [open $RcFile w]
foreach Line $RcData {
        puts $RId $Line
}
close $RId