summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2009-04-20 08:37:47 +0200
committerDanny Baumann <dannybaumann@web.de>2009-04-20 08:37:47 +0200
commit8263b66cf53766a5ce28b27ac604cb602201b8c5 (patch)
treecf17710ed19f6c7fcfdd1dc74336fe3cc2bef22d
parent8e09ecbcb8f5559ac926cea1d176682347f014b4 (diff)
downloadtitleinfo-8263b66cf53766a5ce28b27ac604cb602201b8c5.tar.gz
titleinfo-8263b66cf53766a5ce28b27ac604cb602201b8c5.tar.bz2
Initial commit.
-rw-r--r--CMakeLists.txt3
-rw-r--r--Makefile533
-rw-r--r--dummy0
-rw-r--r--plugin.info2
-rw-r--r--titleinfo.c461
-rw-r--r--titleinfo.xml.in20
6 files changed, 1019 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..c58aad0
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,3 @@
+include (CompizFusion)
+
+compiz_fusion_plugin (titleinfo)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d9a07cf
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,533 @@
+##
+#
+# Compiz plugin Makefile
+#
+# Copyright : (C) 2007 by Dennis Kasprzyk
+# E-mail : onestone@deltatauchi.de
+#
+#
+# This program 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 2
+# of the License, or (at your option) any later version.
+#
+# This program 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.
+#
+##
+
+# plugin.info file contents
+#
+# PLUGIN = foo
+# PKG_DEP = pango
+# LDFLAGS_ADD = -lGLU
+# CFLAGS_ADD = -I/usr/include/foo
+# CHK_HEADERS = compiz-cube.h
+#
+
+#load config file
+
+ECHO = `which echo`
+
+# default color settings
+color := $(shell if [ $$TERM = "dumb" ]; then $(ECHO) "no"; else $(ECHO) "yes"; fi)
+
+ifeq ($(shell if [ -f plugin.info ]; then $(ECHO) -n "found"; fi ),found)
+include plugin.info
+else
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\033[1;31m[ERROR]\033[0m \"plugin.info\" file not found"; \
+ else \
+ $(ECHO) "[ERROR] \"plugin.info\" file not found"; \
+ fi;))
+endif
+
+ifneq ($(shell if pkg-config --exists compiz; then $(ECHO) -n "found"; fi ),found)
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m Compiz not installed"; \
+ else \
+ $(ECHO) -n "[ERROR] Compiz not installed"; \
+ fi))
+endif
+
+
+ifneq ($(shell if [ -n "$(PKG_DEP)" ]; then if pkg-config --exists $(PKG_DEP); then $(ECHO) -n "found"; fi; \
+ else $(ECHO) -n "found"; fi ),found)
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m "; \
+ else \
+ $(ECHO) -n "[ERROR] "; \
+ fi; \
+ pkg-config --print-errors --short-errors --errors-to-stdout $(PKG_DEP); ))
+endif
+
+
+ifeq ($(BUILD_GLOBAL),true)
+ PREFIX = $(shell pkg-config --variable=prefix compiz)
+ CLIBDIR = $(shell pkg-config --variable=libdir compiz)
+ CINCDIR = $(shell pkg-config --variable=includedir compiz)
+ PKGDIR = $(CLIBDIR)/pkgconfig
+ DESTDIR = $(shell pkg-config --variable=libdir compiz)/compiz
+ XMLDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
+ IMAGEDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
+ DATADIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
+else
+ DESTDIR = $(HOME)/.compiz/plugins
+ XMLDIR = $(HOME)/.compiz/metadata
+ IMAGEDIR = $(HOME)/.compiz/images
+ DATADIR = $(HOME)/.compiz/data
+endif
+
+BUILDDIR = build
+
+CC = gcc
+CPP = g++
+LIBTOOL = libtool
+INSTALL = install
+
+BCOP = `pkg-config --variable=bin bcop`
+
+CFLAGS = -g -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing `pkg-config --cflags $(PKG_DEP) compiz ` $(CFLAGS_ADD)
+LDFLAGS = `pkg-config --libs $(PKG_DEP) compiz ` $(LDFLAGS_ADD)
+
+DEFINES = -DIMAGEDIR=\"$(IMAGEDIR)\" -DDATADIR=\"$(DATADIR)\"
+
+POFILEDIR = $(shell if [ -n "$(PODIR)" ]; then $(ECHO) $(PODIR); else $(ECHO) ./po;fi )
+
+COMPIZ_HEADERS = compiz.h compiz-core.h
+COMPIZ_INC = $(shell pkg-config --variable=includedir compiz)/compiz/
+
+is-bcop-target := $(shell if [ -e $(PLUGIN).xml.in ]; then cat $(PLUGIN).xml.in | grep "useBcop=\"true\""; \
+ else if [ -e $(PLUGIN).xml ]; then cat $(PLUGIN).xml | grep "useBcop=\"true\""; fi; fi)
+
+trans-target := $(shell if [ -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml;fi )
+
+bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml; fi )
+bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.c; fi )
+bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.h; fi )
+
+gen-schemas := $(shell if [ \( -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml \) -a -n "`pkg-config --variable=xsltdir compiz-gconf`" ]; then $(ECHO) true; fi )
+schema-target := $(shell if [ -n "$(gen-schemas)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml; fi )
+schema-output := $(shell if [ -n "$(gen-schemas)" ]; then $(ECHO) $(BUILDDIR)/compiz-$(PLUGIN).schema; fi )
+
+ifeq ($(BUILD_GLOBAL),true)
+ pkg-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" ]; then $(ECHO) "$(BUILDDIR)/compiz-$(PLUGIN).pc"; fi )
+ hdr-install-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" -a -e compiz-$(PLUGIN).h ]; then $(ECHO) "compiz-$(PLUGIN).h"; fi )
+endif
+
+# find all the object files
+
+c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
+c-objs += $(patsubst %.cpp,%.lo,$(shell find -name '*.cpp' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
+c-objs += $(patsubst %.cxx,%.lo,$(shell find -name '*.cxx' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
+c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs))
+
+h-files := $(shell find -name '*.h' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')
+h-files += $(bcop-target-hdr)
+h-files += $(foreach file,$(COMPIZ_HEADERS) $(CHK_HEADERS),$(shell $(ECHO) -n "$(COMPIZ_INC)$(file)"))
+
+all-c-objs := $(addprefix $(BUILDDIR)/,$(c-objs))
+all-c-objs += $(bcop-target-src:.c=.lo)
+
+# additional files
+
+data-files := $(shell find data/ -name '*' -type f 2> /dev/null | sed -e 's/data\///')
+image-files := $(shell find images/ -name '*' -type f 2> /dev/null | sed -e 's/images\///')
+
+# system include path parameter, -isystem doesn't work on old gcc's
+inc-path-param = $(shell if [ -z "`gcc --version | head -n 1 | grep ' 3'`" ]; then $(ECHO) "-isystem"; else $(ECHO) "-I"; fi)
+
+# Tests
+ifeq ($(shell if [ -n "$(is-bcop-target)" -a -z "$(BCOP)" ]; then $(ECHO) -n "error"; fi ),error)
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m BCOP not installed but is needed to build plugin"; \
+ else \
+ $(ECHO) -n "[ERROR] BCOP not installed but is needed to build plugin"; \
+ fi))
+endif
+
+ifeq ($(shell if [ "x$(BUILD_GLOBAL)" != "xtrue" -a -e compiz-$(PLUGIN).pc.in ]; then $(ECHO) -n "warn"; fi ),warn)
+$(warning $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[WARNING]\033[0m This plugin might be needed by other plugins. Install it with \"BUILD_GLOBAL=true sudo make install\" "; \
+ else \
+ $(ECHO) -n "[WARNING] This plugin might be needed by other plugins. Install it with \"BUILD_GLOBAL=true sudo make install\""; \
+ fi))
+endif
+
+#
+# Do it.
+#
+
+.PHONY: $(BUILDDIR) build-dir trans-target bcop-build pkg-creation schema-creation c-build-objs c-link-plugin
+
+all: $(BUILDDIR) build-dir trans-target bcop-build pkg-creation schema-creation c-build-objs c-link-plugin
+
+trans-build: $(trans-target)
+
+bcop-build: $(bcop-target-hdr) $(bcop-target-src)
+
+schema-creation: $(schema-output)
+
+c-build-objs: $(all-c-objs)
+
+c-link-plugin: $(BUILDDIR)/lib$(PLUGIN).la
+
+pkg-creation: $(pkg-target)
+
+#
+# Create build directory
+#
+
+$(BUILDDIR) :
+ @mkdir -p $(BUILDDIR)
+
+$(DESTDIR) :
+ @mkdir -p $(DESTDIR)
+
+#
+# fallback if xml.in doesn't exists
+#
+$(BUILDDIR)/%.xml: %.xml
+ @cp $< $@
+
+#
+# Translating
+#
+$(BUILDDIR)/%.xml: %.xml.in
+ @if [ -d $(POFILEDIR) ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mtranslate \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "translate $< -> $@"; \
+ fi; \
+ intltool-merge -x -u $(POFILEDIR) $< $@ > /dev/null; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mtranslate : \033[34m$< -> $@\033[0m"; \
+ fi; \
+ else \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mconvert \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "convert $< -> $@"; \
+ fi; \
+ cat $< | sed -e 's;<_;<;g' -e 's;</_;</;g' > $@; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mconvert : \033[34m$< -> $@\033[0m"; \
+ fi; \
+ fi
+
+#
+# BCOP'ing
+
+$(BUILDDIR)/%_options.h: $(BUILDDIR)/%.xml
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mbcop'ing \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "bcop'ing $< -> $@"; \
+ fi
+ @$(BCOP) --header=$@ $<
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
+ fi
+
+$(BUILDDIR)/%_options.c: $(BUILDDIR)/%.xml
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mbcop'ing \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "bcop'ing $< -> $@"; \
+ fi
+ @$(BCOP) --source=$@ $<
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
+ fi
+
+#
+# Schema generation
+
+$(BUILDDIR)/compiz-%.schema: $(BUILDDIR)/%.xml
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mschema'ing\033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "schema'ing $< -> $@"; \
+ fi
+ @xsltproc `pkg-config --variable=xsltdir compiz-gconf`/schemas.xslt $< > $@
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mschema : \033[34m$< -> $@\033[0m"; \
+ fi
+
+#
+# pkg config file generation
+
+$(BUILDDIR)/compiz-%.pc: compiz-%.pc.in
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mpkgconfig \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "pkgconfig $< -> $@"; \
+ fi
+ @COMPIZREQUIRES=`cat $(PKGDIR)/compiz.pc | grep Requires | sed -e 's;Requires: ;;g'`; \
+ COMPIZCFLAGS=`cat $(PKGDIR)/compiz.pc | grep Cflags | sed -e 's;Cflags: ;;g'`; \
+ sed -e 's;@prefix@;$(PREFIX);g' -e 's;\@libdir@;$(CLIBDIR);g' \
+ -e 's;@includedir@;$(CINCDIR);g' -e 's;\@VERSION@;0.0.1;g' \
+ -e "s;@COMPIZ_REQUIRES@;$$COMPIZREQUIRES;g" \
+ -e "s;@COMPIZ_CFLAGS@;$$COMPIZCFLAGS;g" $< > $@;
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mpkgconfig : \033[34m$< -> $@\033[0m"; \
+ fi
+
+#
+# Compiling
+#
+
+$(BUILDDIR)/%.lo: %.c $(h-files)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "compiling $< -> $@"; \
+ fi
+ @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
+ fi
+
+$(BUILDDIR)/%.lo: $(BUILDDIR)/%.c $(h-files)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "compiling $< -> $@"; \
+ fi
+ @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
+ fi
+
+$(BUILDDIR)/%.lo: %.cpp $(h-files)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "compiling $< -> $@"; \
+ fi
+ @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
+ fi
+
+$(BUILDDIR)/%.lo: %.cxx $(h-files)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "compiling $< -> $@"; \
+ fi
+ @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
+ fi
+
+#
+# Linking
+#
+
+cxx-rpath-prefix := -Wl,-rpath,
+
+$(BUILDDIR)/lib$(PLUGIN).la: $(all-c-objs)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mlinking \033[0m: \033[0;31m$@\033[0m"; \
+ else \
+ $(ECHO) "linking : $@"; \
+ fi
+ @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mlinking : \033[34m$@\033[0m"; \
+ fi
+
+
+clean:
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[0;1;5mremoving \033[0m: \033[0;31m./$(BUILDDIR)\033[0m"; \
+ else \
+ $(ECHO) "removing : ./$(BUILDDIR)"; \
+ fi
+ @rm -rf $(BUILDDIR)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mremoving : \033[34m./$(BUILDDIR)\033[0m"; \
+ fi
+
+
+install: $(DESTDIR) all
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
+ else \
+ $(ECHO) "install : $(DESTDIR)/lib$(PLUGIN).so"; \
+ fi
+ @mkdir -p $(DESTDIR)
+ @$(INSTALL) $(BUILDDIR)/.libs/lib$(PLUGIN).so $(DESTDIR)/lib$(PLUGIN).so
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0minstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
+ fi
+ @if [ -e $(BUILDDIR)/$(PLUGIN).xml ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
+ else \
+ $(ECHO) "install : $(XMLDIR)/$(PLUGIN).xml"; \
+ fi; \
+ mkdir -p $(XMLDIR); \
+ $(INSTALL) $(BUILDDIR)/$(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(hdr-install-target)" ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
+ else \
+ $(ECHO) "install : $(CINCDIR)/compiz/$(hdr-install-target)"; \
+ fi; \
+ $(INSTALL) --mode=u=rw,go=r,a-s $(hdr-install-target) $(CINCDIR)/compiz/$(hdr-install-target); \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0minstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(pkg-target)" ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
+ else \
+ $(ECHO) "install : $(PKGDIR)/compiz-$(PLUGIN).pc"; \
+ fi; \
+ $(INSTALL) --mode=u=rw,go=r,a-s $(pkg-target) $(PKGDIR)/compiz-$(PLUGIN).pc; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0minstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(schema-output)" -a -e "$(schema-output)" ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(schema-output)\033[0m"; \
+ else \
+ $(ECHO) "install : $(schema-output)"; \
+ fi; \
+ if [ "x$(USER)" = "xroot" ]; then \
+ GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
+ gconftool-2 --makefile-install-rule $(schema-output) > /dev/null; \
+ else \
+ gconftool-2 --install-schema-file=$(schema-output) > /dev/null; \
+ fi; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0minstall : \033[34m$(schema-output)\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(data-files)" ]; then \
+ mkdir -p $(DATADIR); \
+ for FILE in $(data-files); do \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \
+ else \
+ $(ECHO) "install : $(DATADIR)/$$FILE"; \
+ fi; \
+ FILEDIR="$(DATADIR)/`dirname "$$FILE"`"; \
+ mkdir -p "$$FILEDIR"; \
+ $(INSTALL) --mode=u=rw,go=r,a-s data/$$FILE $(DATADIR)/$$FILE; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0minstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \
+ fi; \
+ done \
+ fi
+ @if [ -n "$(image-files)" ]; then \
+ mkdir -p $(IMAGEDIR); \
+ for FILE in $(image-files); do \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \
+ else \
+ $(ECHO) "install : $(IMAGEDIR)/$$FILE"; \
+ fi; \
+ FILEDIR="$(IMAGEDIR)/`dirname "$$FILE"`"; \
+ mkdir -p "$$FILEDIR"; \
+ $(INSTALL) --mode=u=rw,go=r,a-s images/$$FILE $(IMAGEDIR)/$$FILE; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0minstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \
+ fi; \
+ done \
+ fi
+
+uninstall:
+ @if [ -e $(DESTDIR)/lib$(PLUGIN).so ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(DESTDIR)/lib$(PLUGIN).so"; \
+ fi; \
+ rm -f $(DESTDIR)/lib$(PLUGIN).so; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
+ fi; \
+ fi
+ @if [ -e $(XMLDIR)/$(PLUGIN).xml ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(XMLDIR)/$(PLUGIN).xml"; \
+ fi; \
+ rm -f $(XMLDIR)/$(PLUGIN).xml; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(hdr-install-target)" -a -e $(CINCDIR)/compiz/$(hdr-install-target) ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(CINCDIR)/compiz/$(hdr-install-target)"; \
+ fi; \
+ rm -f $(CINCDIR)/compiz/$(hdr-install-target); \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(pkg-target)" -a -e $(PKGDIR)/compiz-$(PLUGIN).pc ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(PKGDIR)/compiz-$(PLUGIN).pc"; \
+ fi; \
+ rm -f $(PKGDIR)/compiz-$(PLUGIN).pc; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(schema-output)" -a -e "$(schema-output)" -a 'x$(USER)' = 'xroot' ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(schema-output)\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(schema-output)"; \
+ fi; \
+ GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
+ gconftool-2 --makefile-uninstall-rule $(schema-output) > /dev/null; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(schema-output)\033[0m"; \
+ fi; \
+ fi
+ @if [ -n "$(data-files)" ]; then \
+ for FILE in $(data-files); do \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(DATADIR)/$$FILE"; \
+ fi; \
+ rm -f $(DATADIR)/$$FILE; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \
+ fi; \
+ done \
+ fi
+ @if [ -n "$(image-files)" ]; then \
+ for FILE in $(image-files); do \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(IMAGEDIR)/$$FILE"; \
+ fi; \
+ rm -f $(IMAGEDIR)/$$FILE; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \
+ fi; \
+ done \
+ fi
diff --git a/dummy b/dummy
deleted file mode 100644
index e69de29..0000000
--- a/dummy
+++ /dev/null
diff --git a/plugin.info b/plugin.info
new file mode 100644
index 0000000..35af994
--- /dev/null
+++ b/plugin.info
@@ -0,0 +1,2 @@
+PLUGIN = titleinfo
+
diff --git a/titleinfo.c b/titleinfo.c
new file mode 100644
index 0000000..7743198
--- /dev/null
+++ b/titleinfo.c
@@ -0,0 +1,461 @@
+/*
+ *
+ * Compiz title bar information extension plugin
+ *
+ * titleinfo.c
+ *
+ * Copyright : (C) 2009 by Danny Baumann
+ * E-mail : maniac@compiz.org
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <unistd.h>
+#include <string.h>
+#include <X11/Xatom.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <compiz-core.h>
+#include "titleinfo_options.h"
+
+static int TitleinfoDisplayPrivateIndex;
+
+typedef struct _TitleinfoDisplay {
+ int screenPrivateIndex;
+
+ Atom visibleNameAtom;
+ Atom wmPidAtom;
+
+ HandleEventProc handleEvent;
+} TitleinfoDisplay;
+
+typedef struct _TitleinfoScreen {
+ int windowPrivateIndex;
+} TitleinfoScreen;
+
+typedef struct _TitleinfoWindow {
+ char *title;
+ char *remoteMachine;
+ int owner;
+} TitleinfoWindow;
+
+#define TITLEINFO_DISPLAY(display) PLUGIN_DISPLAY(display, Titleinfo, t)
+#define TITLEINFO_SCREEN(screen) PLUGIN_SCREEN(screen, Titleinfo, t)
+#define TITLEINFO_WINDOW(window) PLUGIN_WINDOW(window, Titleinfo, t)
+
+static void
+titleinfoUpdateVisibleName (CompWindow *w)
+{
+ CompDisplay *d = w->screen->display;
+ char *text = NULL, *machine = NULL;
+ const char *root = NULL, *title;
+
+ TITLEINFO_DISPLAY (d);
+ TITLEINFO_WINDOW (w);
+
+ title = tw->title ? tw->title : "";
+
+ if (titleinfoGetShowRoot (w->screen) && tw->owner == 0)
+ root = "ROOT: ";
+
+ if (titleinfoGetShowRemoteMachine (w->screen) && tw->remoteMachine)
+ {
+ char hostname[256];
+
+ if (gethostname (hostname, 256) || strcmp (hostname, tw->remoteMachine))
+ machine = tw->remoteMachine;
+ }
+
+ if (machine)
+ asprintf (&text, "%s%s (@%s)", root, title, machine);
+ else if (root)
+ asprintf (&text, "%s%s", root, title);
+
+ if (text)
+ {
+ XChangeProperty (d->display, w->id, td->visibleNameAtom,
+ d->utf8StringAtom, 8, PropModeReplace,
+ (unsigned char *) text, strlen (text));
+ free (text);
+ }
+ else
+ {
+ XDeleteProperty (d->display, w->id, td->visibleNameAtom);
+ }
+}
+
+static void
+titleinfoUpdatePid (CompWindow *w)
+{
+ CompDisplay *d = w->screen->display;
+ int pid = -1;
+ Atom type;
+ int result, format;
+ unsigned long nItems, bytesAfter;
+ unsigned char *propVal;
+
+ TITLEINFO_DISPLAY (d);
+ TITLEINFO_WINDOW (w);
+
+ tw->owner = -1;
+
+ result = XGetWindowProperty (d->display, w->id, td->wmPidAtom,
+ 0L, 1L, False, XA_CARDINAL, &type,
+ &format, &nItems, &bytesAfter, &propVal);
+
+ if (result == Success && propVal)
+ {
+ if (nItems)
+ {
+ unsigned long value;
+
+ memcpy (&value, propVal, sizeof (unsigned long));
+ pid = value;
+ }
+
+ XFree (propVal);
+ }
+
+ if (pid >= 0)
+ {
+ char path[512];
+ struct stat fileStat;
+
+ snprintf (path, 512, "/proc/%d/exe", pid);
+ if (!lstat (path, &fileStat))
+ tw->owner = fileStat.st_uid;
+ }
+
+ if (titleinfoGetShowRoot (w->screen))
+ titleinfoUpdateVisibleName (w);
+}
+
+static char *
+titleinfoGetUtf8Property (CompDisplay *d,
+ Window id,
+ Atom atom)
+{
+ Atom type;
+ int result, format;
+ unsigned long nItems, bytesAfter;
+ char *val, *retval = NULL;
+
+ result = XGetWindowProperty (d->display, id, atom, 0L, 65536, False,
+ d->utf8StringAtom, &type, &format, &nItems,
+ &bytesAfter, (unsigned char **) &val);
+
+ if (result != Success)
+ return NULL;
+
+ if (type == d->utf8StringAtom && format == 8 && val && nItems > 0)
+ {
+ retval = malloc (sizeof (char) * (nItems + 1));
+ if (retval)
+ {
+ strncpy (retval, val, nItems);
+ retval[nItems] = 0;
+ }
+ }
+
+ if (val)
+ XFree (val);
+
+ return retval;
+}
+
+static char *
+titleinfoGetTextProperty (CompDisplay *d,
+ Window id,
+ Atom atom)
+{
+ XTextProperty text;
+ char *retval = NULL;
+
+ text.nitems = 0;
+ if (XGetTextProperty (d->display, id, &text, atom))
+ {
+ if (text.value)
+ {
+ retval = malloc (sizeof (char) * (text.nitems + 1));
+ if (retval)
+ {
+ strncpy (retval, (char *) text.value, text.nitems);
+ retval[text.nitems] = 0;
+ }
+
+ XFree (text.value);
+ }
+ }
+
+ return retval;
+}
+
+static void
+titleinfoUpdateTitle (CompWindow *w)
+{
+ CompDisplay *d = w->screen->display;
+ char *title;
+
+ TITLEINFO_WINDOW (w);
+
+ title = titleinfoGetUtf8Property (d, w->id, d->wmNameAtom);
+
+ if (!title)
+ title = titleinfoGetTextProperty (d, w->id, XA_WM_NAME);
+
+ if (tw->title)
+ free (tw->title);
+
+ tw->title = title;
+ titleinfoUpdateVisibleName (w);
+}
+
+
+static void
+titleinfoUpdateMachine (CompWindow *w)
+{
+ TITLEINFO_WINDOW (w);
+
+ if (tw->remoteMachine)
+ free (tw->remoteMachine);
+
+ tw->remoteMachine = titleinfoGetTextProperty (w->screen->display, w->id,
+ XA_WM_CLIENT_MACHINE);
+
+ if (titleinfoGetShowRemoteMachine (w->screen))
+ titleinfoUpdateVisibleName (w);
+}
+
+static void
+titleinfoHandleEvent (CompDisplay *d,
+ XEvent *event)
+{
+ TITLEINFO_DISPLAY (d);
+
+ UNWRAP (td, d, handleEvent);
+ (*d->handleEvent) (d, event);
+ WRAP (td, d, handleEvent, titleinfoHandleEvent);
+
+ if (event->type == PropertyNotify)
+ {
+ CompWindow *w;
+
+ if (event->xproperty.atom == XA_WM_CLIENT_MACHINE)
+ {
+ w = findWindowAtDisplay (d, event->xproperty.window);
+ if (w)
+ titleinfoUpdateMachine (w);
+ }
+ else if (event->xproperty.atom == td->wmPidAtom)
+ {
+ w = findWindowAtDisplay (d, event->xproperty.window);
+ if (w)
+ titleinfoUpdatePid (w);
+ }
+ else if (event->xproperty.atom == d->wmNameAtom ||
+ event->xproperty.atom == XA_WM_NAME)
+ {
+ w = findWindowAtDisplay (d, event->xproperty.window);
+ if (w)
+ titleinfoUpdateTitle (w);
+ }
+ }
+}
+
+static Bool
+titleinfoInitDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ TitleinfoDisplay *td;
+
+ if (!checkPluginABI ("core", CORE_ABIVERSION))
+ return FALSE;
+
+ td = malloc (sizeof (TitleinfoDisplay));
+ if (!td)
+ return FALSE;
+
+ td->screenPrivateIndex = allocateScreenPrivateIndex (d);
+ if (td->screenPrivateIndex < 0)
+ {
+ free (td);
+ return FALSE;
+ }
+
+ td->visibleNameAtom = XInternAtom (d->display, "_NET_WM_VISIBLE_NAME", 0);
+ td->wmPidAtom = XInternAtom (d->display, "_NET_WM_PID", 0);
+
+ WRAP (td, d, handleEvent, titleinfoHandleEvent);
+
+ d->base.privates[TitleinfoDisplayPrivateIndex].ptr = td;
+
+ return TRUE;
+}
+
+static void
+titleinfoFiniDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ TITLEINFO_DISPLAY (d);
+
+ freeScreenPrivateIndex (d, td->screenPrivateIndex);
+
+ UNWRAP (td, d, handleEvent);
+
+ free (td);
+}
+
+static Bool
+titleinfoInitScreen (CompPlugin *p,
+ CompScreen *s)
+{
+ TitleinfoScreen *ts;
+
+ TITLEINFO_DISPLAY (s->display);
+
+ ts = malloc (sizeof (TitleinfoScreen));
+ if (!ts)
+ return FALSE;
+
+ ts->windowPrivateIndex = allocateWindowPrivateIndex (s);
+ if (ts->windowPrivateIndex < 0)
+ {
+ free (ts);
+ return FALSE;
+ }
+
+ s->base.privates[td->screenPrivateIndex].ptr = ts;
+
+ return TRUE;
+}
+
+static void
+titleinfoFiniScreen (CompPlugin *p,
+ CompScreen *s)
+{
+ TITLEINFO_SCREEN (s);
+
+ freeWindowPrivateIndex (s, ts->windowPrivateIndex);
+
+ free (ts);
+}
+
+static Bool
+titleinfoInitWindow (CompPlugin *p,
+ CompWindow *w)
+{
+ TitleinfoWindow *tw;
+
+ TITLEINFO_SCREEN (w->screen);
+
+ tw = malloc (sizeof (TitleinfoWindow));
+ if (!tw)
+ return FALSE;
+
+ tw->remoteMachine = NULL;
+ tw->title = NULL;
+ tw->owner = -1;
+
+ w->base.privates[ts->windowPrivateIndex].ptr = tw;
+
+ titleinfoUpdateTitle (w);
+ titleinfoUpdateMachine (w);
+ titleinfoUpdatePid (w);
+ titleinfoUpdateVisibleName (w);
+
+ return TRUE;
+}
+
+static void
+titleinfoFiniWindow (CompPlugin *p,
+ CompWindow *w)
+{
+ TITLEINFO_WINDOW (w);
+
+ if (tw->title)
+ free (tw->title);
+
+ if (tw->remoteMachine)
+ free (tw->remoteMachine);
+
+ tw->remoteMachine = NULL;
+ titleinfoUpdateVisibleName (w);
+
+ free (tw);
+}
+
+static CompBool
+titleinfoInitObject (CompPlugin *p,
+ CompObject *o)
+{
+ static InitPluginObjectProc dispTab[] = {
+ (InitPluginObjectProc) 0, /* InitCore */
+ (InitPluginObjectProc) titleinfoInitDisplay,
+ (InitPluginObjectProc) titleinfoInitScreen,
+ (InitPluginObjectProc) titleinfoInitWindow
+ };
+
+ RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
+}
+
+static void
+titleinfoFiniObject (CompPlugin *p,
+ CompObject *o)
+{
+ static FiniPluginObjectProc dispTab[] = {
+ (FiniPluginObjectProc) 0, /* FiniCore */
+ (FiniPluginObjectProc) titleinfoFiniDisplay,
+ (FiniPluginObjectProc) titleinfoFiniScreen,
+ (FiniPluginObjectProc) titleinfoFiniWindow
+ };
+
+ DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
+}
+
+static Bool
+titleinfoInit (CompPlugin *p)
+{
+ TitleinfoDisplayPrivateIndex = allocateDisplayPrivateIndex ();
+ if (TitleinfoDisplayPrivateIndex < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+titleinfoFini (CompPlugin *p)
+{
+ freeDisplayPrivateIndex (TitleinfoDisplayPrivateIndex);
+}
+
+CompPluginVTable titleinfoVTable = {
+ "titleinfo",
+ 0,
+ titleinfoInit,
+ titleinfoFini,
+ titleinfoInitObject,
+ titleinfoFiniObject,
+ 0,
+ 0
+};
+
+CompPluginVTable *
+getCompPluginInfo (void)
+{
+ return &titleinfoVTable;
+}
diff --git a/titleinfo.xml.in b/titleinfo.xml.in
new file mode 100644
index 0000000..3ae817f
--- /dev/null
+++ b/titleinfo.xml.in
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<compiz>
+ <plugin name="titleinfo" useBcop="true">
+ <_short>Title Bar Info</_short>
+ <_long>Shows additional information in the window title bar</_long>
+ <category>Utility</category>
+ <screen>
+ <option name="show_remote_machine" type="bool">
+ <_short>Show Remote Machine Name</_short>
+ <_long>Show name of remote machine if a certain application is executed remotely.</_long>
+ <default>true</default>
+ </option>
+ <option name="show_root" type="bool">
+ <_short>Show Root</_short>
+ <_long>Show marker if you're logged in as root.</_long>
+ <default>true</default>
+ </option>
+ </screen>
+ </plugin>
+</compiz>