diff --git a/Makefile.am b/Makefile.am index bb5d33ac..7ee928bf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,9 @@ bin_PROGRAMS=rofi dist_bin_SCRIPTS=script/rofi-sensible-terminal +nodist_rofi_SOURCES=\ + $(top_builddir)/gitconfig.h + rofi_SOURCES=\ source/rofi.c\ source/view.c\ @@ -122,6 +125,7 @@ EXTRA_DIST=\ INSTALL.md\ AUTHORS\ doc/rofi.doxy.in\ + script/get_git_rev.sh\ Changelog ## @@ -305,3 +309,13 @@ ohcount: $(rofi_SOURCES) doxy: doc/rofi.doxy $(rofi_SOURCES) doxygen $(top_builddir)/doc/rofi.doxy +clean-local: + -rm $(top_builddir)/gitconfig.h + +$(top_builddir)/gitconfig.h: .FORCE + $(top_srcdir)/script/get_git_rev.sh $(top_srcdir) $(top_builddir)/gitconfig.h + +$(rofi_SOURCES): $(top_builddir)/gitconfig.h + +.PHONY: .FORCE +.FORCE: diff --git a/script/get_git_rev.sh b/script/get_git_rev.sh new file mode 100755 index 00000000..c5ef9457 --- /dev/null +++ b/script/get_git_rev.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +DIR=$1 +FILE=$2 + +if [ -d "${DIR}/.git/" ] +then + echo -n "#define GIT_VERSION \"" > ${FILE}.tmp + REV=$(git log -1 --pretty=tformat:%h) + echo -n "${REV}" >> ${FILE}.tmp + echo "\"" >> ${FILE}.tmp +else + echo "#undef GIT_VERSION" > ${FILE}.tmp +fi + +if ! diff ${FILE}.tmp ${FILE} > /dev/null +then + mv ${FILE}.tmp ${FILE} +else + rm ${FILE}.tmp +fi diff --git a/source/dialogs/window.c b/source/dialogs/window.c index f224f0e6..940ca4fc 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -419,7 +419,7 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd ) && !client_has_window_type ( c, xcb->ewmh._NET_WM_WINDOW_TYPE_DESKTOP ) && !client_has_state ( c, xcb->ewmh._NET_WM_STATE_SKIP_PAGER ) && !client_has_state ( c, xcb->ewmh._NET_WM_STATE_SKIP_TASKBAR ) ) { - classfield = MAX ( classfield, strlen ( c->class ) ); + classfield = MAX ( classfield, (c->class != NULL)?(strlen ( c->class )):0 ); if ( client_has_state ( c, xcb->ewmh._NET_WM_STATE_DEMANDS_ATTENTION ) ) { c->demands = TRUE; diff --git a/source/rofi.c b/source/rofi.c index efeac421..1c6906db 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -63,6 +63,8 @@ #include "view.h" #include "view-internal.h" +#include "gitconfig.h" + // Pidfile. char *pidfile = NULL; const char *cache_dir = NULL; @@ -303,6 +305,9 @@ static void help ( G_GNUC_UNUSED int argc, char **argv ) printf ( "\n" ); printf ( "For more information see: man rofi\n" ); printf ( "Version: "VERSION "\n" ); +#ifdef GIT_VERSION + printf ( "Git: "GIT_VERSION "\n"); +#endif printf ( "Bugreports: "PACKAGE_BUGREPORT "\n" ); } @@ -605,6 +610,9 @@ int main ( int argc, char *argv[] ) // Version if ( find_arg ( "-v" ) >= 0 || find_arg ( "-version" ) >= 0 ) { fprintf ( stdout, "Version: "VERSION "\n" ); +#ifdef GIT_VERSION + fprintf ( stdout, "Git: "GIT_VERSION "\n"); +#endif exit ( EXIT_SUCCESS ); }