No Description

ohnonot 978f5b39b6 github to notabug 3 months ago
xbm 978f5b39b6 github to notabug 3 months ago
README.md a5ca668688 big cleanup 2 years ago
config 978f5b39b6 github to notabug 3 months ago
dmenu 37c15aada1 many changes 2 years ago
getcolors_gtk2.py 978f5b39b6 github to notabug 3 months ago
getcolors_gtk3.py 978f5b39b6 github to notabug 3 months ago
gtkroot 37c15aada1 many changes 2 years ago
new.xml 978f5b39b6 github to notabug 3 months ago
posix_compliant_random_functions ea006e429c so many changes. also removed conky support, and added tint2. 2 years ago
rc.xml 978f5b39b6 github to notabug 3 months ago
test_tv3.py 978f5b39b6 github to notabug 3 months ago
wait_for_theme_change 978f5b39b6 github to notabug 3 months ago
xappspicker 978f5b39b6 github to notabug 3 months ago
xappspicker.old 9fd9e000a8 First commit 2 years ago

README.md

Various scripts to unify looks between GTK and other graphical apps

What's the idea of xappspicker?

Many applications are stylable, but do not follow your current GTK theme's style.

The idea is to extract a few key colors, namely

  1. base foreground
  2. base background
  3. selected text foreground
  4. selected text background

from your current GTK2 theme and apply them to these applications.

That is, if you like and use apps like tint2, dmenu, or Xapps like xpdf, xfontsel, xsetroot (and its use of 2-tone bitmaps).

What does xappspicker do ?

By default, not much. It will only change background and foreground colors for some X apps, namely XFontSel, Display, Bitmap, Xmag, Xman, Xpdf, Xscreensaver.

How do I use it?

You can simply execute the script everytime you want to.
You can make a symlink to the executable somewhere in your $PATH, e.g.:

cd $HOME/bin
ln -s /path/to/xscripts/xappspicker

But do not copy the script over, because it relies on some files to be in the same directory.

Ok, but how do I really use it? What does it really do?

There are many modules that aren't enabled by default.
You should copy the config file from the script's folder to $HOME/.config/xappspicker/config and make your adjustments:

xapps_enabled=1
# custom Xresources will be merged with xrdb. see $xres below.

xsetroot_enabled=0
# background will be set according to color manipulations and other rules below

dmenu_enabled=1
#dmenurc="$HOME/.config/dmenu/dmenurc"
# dmenu colors will be set, if a dmenurc file is found (to actually use this, 
# one needs a wrapper around dmenu. an example is included in this repo).

tint2_enabled=0
# if the theme folder includes tint2/tint2rc (a tint2rc file in a tint2 subfolder)
# it will be launched. an instance of tint2 previously launched by this script will be killed.
tint2_is_essential=1
# 1: if the theme does not contain a tint2rc, launch the default
# 0: if the theme does not contain a tint2rc, don't launch anything.
#    an instance of tint2 previously launched by this script will still be killed.

conky_enabled=0
# if the theme folder includes conky/conkyrc (a conkyrc file in a conky subfolder)
# it will be launched. an instance of conky previously launched by this script will be killed.
conky_is_essential=0
# 1: if the theme does not contain a conkyrc, launch the default
# 0: if the theme does not contain a conkyrc, don't launch anything.
#    an instance of conky previously launched by this script will still be killed.

openbox_enabled=0
#obrc="$HOME/.config/openbox/rc.xml"
# if an openbox theme exists for the current gtk2 theme, replace the theme name 
# in openbox' rc.xml, and reconfigure.
# If items in rc.xml are in an unusal, yet valid order, this might go wrong (e.g.
# if a theme name is the same as a font name, and the font is defined before the theme).

exec_enabled=0
#exec_path="" # defaults to $themepath/xappspicker.exec
# search for an executable, and execute it. does not need to be a shell script or
# even a script at all.

dmenufont="terminus"
# font definitions in dmenu 4.6 are unclear to me. they also differ from
# suckless-tools 4.5 - one cannot pass xfont-strings.
# the one below should work on all systems, or at least fail silently.
# set to empty string to use default font.

# prepare the values for xsetroot. please see man xsetroot.
# 1.: do you want to choose a random bitmap from the following dir?
#     if not, set this to "", and xsetroot will choose:
#      a) the file xsetrootbitmap.xbm from $themedir, or, failing that
#      b) a random -mod.
# bitmap directory, relative to the script's path
bitmapdir="xbm/squidfingers"
# 2.: which color to choose as a base for the background? I choose the background for
#     selected text, usually the most colorful accent in the theme. It's the 4th and
#     last color in the array generated by grepcol() = $sel_txt_bg
# 3.: manipulate that color. 
#     a) i prefer to darken the background to 20%, and the foreground to 10%
xsetrootbg="$(fixed_value "$sel_txt_bg" "0.2")"
xsetrootfg="$(fixed_value "$sel_txt_bg" "0.1")"
#     b) another possibility: color-invert (=negative) the colors
#~ xsetrootbg="$(invert "$base_fg")" # that is the foreground
#~ xsetrootfg="$(invert "$base_bg")" # that is the background
# functions can be combined, too.

# which xapps will be affected, and which color chosen? un/comment or add values.
# this multiline variable will be piped to xrdb. see "man xrdb" for valid syntax.
# also have a look at /usr/share/X11/app-defaults
# please keep in mind that a leading '!' means 'commented out'
### start of xres variable ###
xres="!!! background values
! XCalc.ti.Command.background: $base_bg
! XCal*background: $base_bg
XFontSel*background:  $base_bg
display.background:  $base_bg
bitmap*background:  $base_bg
Xmag*background:  $base_bg
Xmag*helpLabel*background:  $base_fg
Xman*background:  $base_bg
xpdf*background:  $base_bg
xpdf*matteColor:  $base_bg
xscreensaver*background:  $base_bg
! URxvt*borderColor:  $base_bg
! *background:  $base_bg
!!! foreground values
! XCalc.ti.Command.foreground: $base_fg
! XCal*foreground: $base_fg
XFontSel*foreground: $base_fg
display.foreground: $base_fg
bitmap*foreground: $base_fg
Xmag*foreground: $base_fg
Xmag*helpLabel*foreground:  $base_bg
Xman*foreground: $base_fg
xpdf*foreground: $base_fg
xscreensaver*foreground: $base_fg
! *foreground: $base_fg"
### end of xres variable ###*

Important usage suggestions

The current theme folder is chosen through the file ~/.gtkrc-2.0, which is typically modified by an application like lxapearance (works great on any desktop), but can also be edited manually.

It is possible to simply run the script as is at login.

However, it isn't exactly fast and might create a noticeable lag during login.

To avoid that, the script generates a file $HOME/.local/share/xorg/xappspicker_rc.
The idea is:

  • Instead of executing the script, source $HOME/.local/share/xorg/xappspicker_rc at login.
  • Set up inotifywatch (or some such) to watch for changes in ~/.gtkrc-2.0 and execute the script only when needed.

You can achieve this by adding something like this to your autostart file (typically ~/.xinitrc or ~/.config/openbox/autostart):

dash -c '. "$HOME/.local/share/xorg/xappspicker_rc";sleep 5; while :; do inotifywait -e modify $HOME/.gtkrc-2.0; /path/to/xappspicker; done' &

I recommend using dash instead of bash; it is much faster, and everything has been tested to work with dash's limited capabilities.

I have added a large collection of .xbm tiles suitable for xsetroot; they're in xbm and subfolders.

Requirements:

  • python 2.x, and the gtk module. I'm fairly sure that this is included in a package called pygtk. And you most probably already have it.
  • xsetroot
  • a fairly recent version of bash, I'd guess.
  • bc (command line calculator).
  • hexdump and shuf for the posix compliant random functions.
  • the adjust_tint2 and adjust_conky functions rely on pgrep
  • the change_openbox_theme function relies on xmllint
  • common utilities like sed and cut and grep...

Tips

You can quickly create .xbm tiles with the bitmap program.

Try out the xappspicker.py script to see what other color values can be accessed (un/comment some sections).

Known limitations

  • Openbox theme plugin:
    The theme name is extracted with xmllint, but replaced with sed.
    If items in rc.xml are in an unusal, yet valid order, this might go wrong (e.g. if a theme name is the same as a font name, and the font is defined before the theme). I don't think the sed command is destructive, but just in case, the script copies rc.xml to a backup file.
  • Conky plugin:
    conky changes its pid when it has the "background yes" configuration option, and so saving $! to a pidfile saves the wrong pid. to be able to kill the appropiate process, we uniquely identify this instance of conky by launching it with a bogus command line option: -a xappspicker_identifier. to my knowledge, conky is not affected by that.

also see this forum thread.