[PATCH] Change the user directory where wmiirc lives.

2 views
Skip to first unread message

dcurtis

unread,
Mar 5, 2009, 4:40:08 PM3/5/09
to wmii...@googlegroups.com

This patch just replaces .wmii-3.5 with .wmii-lua for all the files in the repo
so they can live in .wmii-lua rather than .wmii-3.5 which changes w/ every
version of wmii.

Bart Trojanowski

unread,
Mar 17, 2009, 8:28:25 PM3/17/09
to wmii...@googlegroups.com, Donald E Curtis
* dcurtis <dcu...@cs.uiowa.edu> [090305 15:40]:

> This patch just replaces .wmii-3.5 with .wmii-lua for all the files in the repo
> so they can live in .wmii-lua rather than .wmii-3.5 which changes w/ every
> version of wmii.

I don't have a problem with this. It's probably a good idea long term.
I'd like to have it backwards compatible for at least a little while
with the original (poorly chosen name) for the user installed files.
As it stands the scripts could silently fail to load after upgrade.

Perhaps a warning in the 'make install-user' and 'install-wmiirc-lua'
about the change of default directories is required, if the user has the
old files installed.

For extra credit, wmii-lua could put up an xdialog or something if the
user has both .wmii-3.5 and .wmii-lua populated with lua files.

An alternative would be to look in both places. I am open to either.

Thanks,

-Bart

--
WebSig: http://www.jukie.net/~bart/sig/

Donald Ephraim Curtis

unread,
Mar 17, 2009, 9:33:03 PM3/17/09
to Bart Trojanowski, wmii...@googlegroups.com
My brain is kinda out of it right now so some of this may not make
sense.

***
Initially this was your idea. The only reason I was wanting it was
because I use the wmii-hg and that uses .wmii-hg but the lua scripts are
hardcoded to use .wmii-3.5

So, using .wmii-lua is a solution to my problem.

***
It would also be a solution to determine at compile time, what directory
is being used by wmii.

There is a file "/usr/bin/wmiistartrc" that could be used to
automatically detect the installed version of wmii. Or at least it
could detect the default install locations.


***
On a side note, what is the purpose of the wmii-lua besides being able
to fallback to the regular scripts.


***
The other thing I am curious about: what about separating the scripts
from the ixp library? It seems to me that it would be nice that they
weren't packaged together and the ixp library was separate so that i
could tell people, install luaixp and then just use my scripts, rather
than requiring the install-home and wmii-lua scripts.

If we could do this, I think it would resolve the entire issue, people
could install the scripts locally to their home directory, or somewhere
else. I could work on a patch to this if you're interested.


--
Donald

(Tue, Mar 17, 2009 at 08:28:25PM -0400) Bart Trojanowski <ba...@jukie.net>:

Bart Trojanowski

unread,
Mar 17, 2009, 10:32:33 PM3/17/09
to wmii...@googlegroups.com, Donald Ephraim Curtis
* Donald Ephraim Curtis <dcu...@cs.uiowa.edu> [090317 21:33]:

> There is a file "/usr/bin/wmiistartrc" that could be used to
> automatically detect the installed version of wmii. Or at least it
> could detect the default install locations.
>
> On a side note, what is the purpose of the wmii-lua besides being able
> to fallback to the regular scripts.

The wmiistartrc is part of wmii. I'd prefer not to override the way in
which wmii w/ shell wmiirc works.

wmii-lua is meant to be a way to start wmii with lua as the rc script.

> The other thing I am curious about: what about separating the scripts
> from the ixp library? It seems to me that it would be nice that they
> weren't packaged together and the ixp library was separate so that i
> could tell people, install luaixp and then just use my scripts, rather
> than requiring the install-home and wmii-lua scripts.

If you want to package this for your distro you should be able to do
that regardless of where I install things, right?

> If we could do this, I think it would resolve the entire issue, people
> could install the scripts locally to their home directory, or somewhere
> else. I could work on a patch to this if you're interested.

With Debian, the intent is to install a deb, and then run
install-wmiirc-lua to install the wmiirc in ~/.wmii-lua/ dir.

Maybe I am missing what you're attempting to do.

Donald Ephraim Curtis

unread,
Mar 18, 2009, 1:12:56 AM3/18/09
to Bart Trojanowski, wmii...@googlegroups.com
This relates to the other email about moving to .wmii-lua...

What I meant is that in resolve to hardcoding .wmii-3.5 in the
wmiirc-lua source, you could have the make script search for the
wmiistartrc file and automatically detect the directories to install to.

Right now you have a variable (HOME_WMII) in the config.mk file that
designates the home directory etc, but HOME_WMII does _not_ replace the
paths in "wmii-lua" _nor_ "wmiirc.lua"


So I am proposing two options:

1) have your package detect the directories to use for installation,
namely .wmii-* and find the desired * by looking at wmiistartrc.

2) use .wmii-lua always everywhere.

There is one reason I don't like #2: you need to use wmii-lua to start
wmii. I would kinda like something more standard where you can use #1
and just have wmiirc in your "standard" wmii directory. This avoids
even having to bother with wmii-lua at all which I do like.

Is there a possibility we could do both? :)


(Tue, Mar 17, 2009 at 10:32:33PM -0400) Bart Trojanowski <ba...@jukie.net>:

Bart Trojanowski

unread,
Mar 18, 2009, 10:20:25 PM3/18/09
to Donald Ephraim Curtis, wmii...@googlegroups.com
Thanks for brainstorming this.

* Donald Ephraim Curtis <dcu...@cs.uiowa.edu> [090318 01:13]:


> Right now you have a variable (HOME_WMII) in the config.mk file that
> designates the home directory etc, but HOME_WMII does _not_ replace the
> paths in "wmii-lua" _nor_ "wmiirc.lua"

Ok, that's bad. I'll fix that up by shipping a bunch of .in files and
convert them at build time.

> 1) have your package detect the directories to use for installation,
> namely .wmii-* and find the desired * by looking at wmiistartrc.

I don't like parsing the wmiistartrc.

> 2) use .wmii-lua always everywhere.
>
> There is one reason I don't like #2: you need to use wmii-lua to start
> wmii. I would kinda like something more standard where you can use #1
> and just have wmiirc in your "standard" wmii directory. This avoids
> even having to bother with wmii-lua at all which I do like.

I like #2 because people can still run wmii w/ shell or wmii w/ lua
wmiirc scripts from the same install.

I don't know if you noticed, but the wmii-lua.desktop file is installed
in /usr/share/xsessions which makes it available in the GDM/KDM desktop
drop down.

> Is there a possibility we could do both? :)

To an extent we can do this. config.mk is meant to be edited before
install. This allows you to install the software how you want. With
the fix I proposed above things should be more consistent.

I'd be open to a ./configure script that has the smarts you suggest in
#1 and generates config.mk from a config.mk.in appropriately. It does
not have to be a autotools based configure script... those are ugly and
I don't really care (yet) if this stuff runs on HP/UX and AIX. I am
expecting gcc on Linux. :)

Maybe:

./configure [ --prefix=... ] [ --user-prefix=... ] \
[ --parse-wmiistartrc[=location] ]

--prefix - set PREFIX variable
--user-prefix - set the HOME_WMII variable
--parse-wmiistartrc - set the PREFIX and HOME_WMII based on lconf
and gconf found in wmiistartrc

Also, install-wmiirc-lua might need to be modified to include a
--prefix= switch that controls the location of the .wmii-lua files.
Although that would require a custom wmii-lua in the user's $HOME/bin.

Bart Trojanowski

unread,
Mar 19, 2009, 12:15:45 AM3/19/09
to Donald Ephraim Curtis, wmii...@googlegroups.com
* Bart Trojanowski <ba...@jukie.net> [090318 22:20]:

> * Donald Ephraim Curtis <dcu...@cs.uiowa.edu> [090318 01:13]:
> > Right now you have a variable (HOME_WMII) in the config.mk file that
> > designates the home directory etc, but HOME_WMII does _not_ replace the
> > paths in "wmii-lua" _nor_ "wmiirc.lua"
>
> Ok, that's bad. I'll fix that up by shipping a bunch of .in files and
> convert them at build time.

I've pushed some changes to address this in the 'pu' branch, the patch
for discussion is below.

I went through the 4 files that referenced real paths and renamed them
to have a .in suffix. I then substituted the path strings with one of
%DESTDIR%, %PREFIX%, %RC_DIR%, %LUA_BIN%, or %HOME_WMII%. These are
substituted with the real variable read from config.mk by the Makefile.

I have done minimal testing, but not actually ran this yet. Have a look
see if that'd address most of the issues.

-Bart

--

From a08d2d5594b030d6bd11ae41b4ccf144a1da958a Mon Sep 17 00:00:00 2001
From: Bart Trojanowski <ba...@jukie.net>
Date: Wed, 18 Mar 2009 23:01:26 -0400
Subject: [PATCH] generate a handful of files with substitutions from config.mk

---
Makefile | 38 ++++++++++++++++++--------
config.mk.dist => config.mk.in | 3 +-
core/{wmii.lua => wmii.lua.in} | 17 ++++++-----
install-wmiirc-lua => install-wmiirc-lua.in | 4 +-
wmii-lua => wmii-lua.in | 8 +++---
wmiirc.lua => wmiirc.lua.in | 2 +-
6 files changed, 44 insertions(+), 28 deletions(-)
rename config.mk.dist => config.mk.in (99%)
rename core/{wmii.lua => wmii.lua.in} (99%)
rename install-wmiirc-lua => install-wmiirc-lua.in (95%)
rename wmii-lua => wmii-lua.in (82%)
rename wmiirc.lua => wmiirc.lua.in (98%)

diff --git a/Makefile b/Makefile
index 32ab40d..018ca29 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,3 @@
-include config.mk
-
MAN = wmii.3lua

# run make V=1 to see all commands
@@ -8,8 +6,8 @@ Q = $(if ${V},,@)
# ------------------------------------------------------------------------
# main target

-.PHONY: all help deb debi libs luaixp luaeventloop docs man clean distclean tags install install-user install-variable-check install-user-variable-check
-all: libs man
+.PHONY: all help deb debi libs luaixp luaeventloop docs man clean distclean tags install install-user install-variable-check install-user-variable-check generate-from-in
+all: generate-from-in libs man

help:
@echo "make [target]"
@@ -37,12 +35,28 @@ deb:
debi: deb
sudo debi

-config.mk: config.mk.dist
- if test -f $@ ; then \
- touch $@ ; \
- else \
- cp $< $@ ; \
- fi
+$(if $(wildcard config.mk),,$(shell cp config.mk.in config.mk))
+include config.mk
+
+GEN_SRC = core/wmii.lua.in install-wmiirc-lua.in wmii-lua.in wmiirc.lua.in
+GEN_DST = ${GEN_SRC:%.in=%}
+
+generate-from-in: ${GEN_DST}
+${GEN_DST}: config.mk
+${GEN_DST}: %: %.in
+ifeq (${LOADED_CONFIG_MK},)
+ ${MAKE} config.mk
+ ${MAKE} $@
+else
+ @echo Generating $@
+ ${Q} sed -e 's:%DESTDIR%:${DESTDIR}:' \
+ -e 's:%PREFIX%:${PREFIX}:' \
+ -e 's:%RC_DIR%:${RC_DIR}:' \
+ -e 's:%LUA_BIN%:${LUA_BIN}:' \
+ -e 's:%HOME_WMII%:${HOME_WMII}:' \
+ $< > $@
+endif
+

# ------------------------------------------------------------------------
# building
@@ -72,7 +86,7 @@ clean:
-${MAKE} -C luaeventloop clean

distclean: clean
- -rm -f config.mk
+ -rm -f config.mk ${GEN_DST}

# ------------------------------------------------------------------------
# installing
@@ -80,7 +94,7 @@ distclean: clean
#
# install system wide
#
-install: ${MAN} install-variable-check
+install: ${MAN} ${GEN_DST} install-variable-check
# create directories
${Q} ${INSTALL} -d ${ALL_INSTALL_DIRS}
#
diff --git a/config.mk.dist b/config.mk.in
similarity index 99%
rename from config.mk.dist
rename to config.mk.in
index 3d68224..807c5de 100644
--- a/config.mk.dist
+++ b/config.mk.in
@@ -1,4 +1,4 @@
-# vim: set ft=make :
+LOADED_CONFIG_MK := 1
# ------------------------------------------------------------------------
# standard programs
CC = cc
@@ -70,3 +70,4 @@ ALL_HOME_DIRS = ${HOME_CORE} \
${HOME_PLUGINS} \
${HOME_PLUGINS}

+# vim: set ft=make :
diff --git a/core/wmii.lua b/core/wmii.lua.in
similarity index 99%
rename from core/wmii.lua
rename to core/wmii.lua.in
index 1f675d1..772d3ca 100644
--- a/core/wmii.lua
+++ b/core/wmii.lua.in
@@ -55,7 +55,7 @@ It should be used by your wmiirc
-- MODULE SETUP
-- ========================================================================

-local wmiidir = os.getenv("HOME") .. "/.wmii-lua"
+local wmiidir = ("%HOME_WMII%"):gsub("^~", os.getenv("HOME"))
local wmiirc = wmiidir .. "/wmiirc"

package.path = wmiidir .. "/core/?.lua;" ..
@@ -145,8 +145,8 @@ local action_hist = history.new(10)
-- where to find plugins
plugin_paths = {}

-table.insert(plugin_paths, os.getenv("HOME") .. "/.wmii-lua/plugins/?.so")
-table.insert(plugin_paths, os.getenv("HOME") .. "/.wmii-lua/plugins/?.lua")
+table.insert(plugin_paths, wmiidir .. "/plugins/?.so")
+table.insert(plugin_paths, wmiidir .. "/plugins/?.lua")

for path in string.gmatch(package.path, "[^;]+") do
if not path:find("^./") and not path:find("core") and not path:find("plugins") then
@@ -163,10 +163,10 @@ for path in string.gmatch(package.cpath, "[^;]+") do
end

-- where to find wmiirc (see find_wmiirc())
-wmiirc_path = os.getenv("HOME") .. "/.wmii-lua/wmiirc.lua;"
- .. os.getenv("HOME") .. "/.wmii-lua/wmiirc;"
- .. "/etc/X11/wmii-lua/wmiirc.lua;"
- .. "/etc/X11/wmii-lua/wmiirc"
+wmiirc_path = wmiidir .. "/wmiirc.lua;"
+ .. wmiidir .. "/wmiirc;"
+ .. "%RC_DIR%/wmiirc.lua;"
+ .. "%RC_DIR%/wmiirc"

-- ========================================================================
-- LOCAL HELPERS
@@ -194,7 +194,7 @@ end

=item find_wmiirc ( )

-Locates the wmiirc script. It looks in ~/.wmii-lua and /etc/X11/wmii-lua
+Locates the wmiirc script. It looks in %HOME_WMII% and %RC_DIR%
for the first lua script bearing the name wmiirc.lua or wmiirc. Returns
first match.

@@ -594,6 +594,7 @@ local action_handlers = {
cleanup()
posix.exec (wmiirc)
posix.exec ("/bin/sh", "-c", "exec lua wmiirc")
+ posix.exec ("%LUA_BIN%", wmiirc)
posix.exec ("/usr/bin/lua", wmiirc)
end
else
diff --git a/install-wmiirc-lua b/install-wmiirc-lua.in
similarity index 95%
rename from install-wmiirc-lua
rename to install-wmiirc-lua.in
index 0948925..417f4aa 100755
--- a/install-wmiirc-lua
+++ b/install-wmiirc-lua.in
@@ -5,8 +5,8 @@

set -e

-SRC_DIR="/etc/wmii-lua"
-DST_DIR="${HOME}/.wmii-lua"
+SRC_DIR="%RC_DIR%"
+DST_DIR=$(echo "%HOME_WMII%")

SRC_WMIIRC="${SRC_DIR}/wmiirc.lua"
DST_WMIIRC="${DST_DIR}/wmiirc"
diff --git a/wmii-lua b/wmii-lua.in
similarity index 82%
rename from wmii-lua
rename to wmii-lua.in
index a436f30..2b9d179 100755
--- a/wmii-lua
+++ b/wmii-lua.in
@@ -6,10 +6,10 @@

# we will look for wmiirc in these directories
POSSIBLE_WMIIRC="
-${HOME}/.wmii-lua/wmiirc.lua
-${HOME}/.wmii-lua/wmiirc
-/etc/wmii-lua/wmiirc.lua
-/etc/wmii-lua/wmiirc
+%HOME_WMII%/wmiirc.lua
+%HOME_WMII%/wmiirc
+%RC_DIR%/wmiirc.lua
+%RC_DIR%/wmiirc
"

# try to find the best wmiirc written in lua
diff --git a/wmiirc.lua b/wmiirc.lua.in
similarity index 98%
rename from wmiirc.lua
rename to wmiirc.lua.in
index 25db765..04204c6 100755
--- a/wmiirc.lua
+++ b/wmiirc.lua.in
@@ -14,7 +14,7 @@
io.stderr:write ("----------------------------------------------\n")

-- load wmii.lua
-local wmiidir = os.getenv("HOME") .. "/.wmii-lua"
+local wmiidir = ("%HOME_WMII%"):gsub("^~", os.getenv("HOME"))
package.path = wmiidir .. "/core/?.lua;" ..
wmiidir .. "/plugins/?.lua;" ..
package.path
--
1.6.2.rc2.17.gcdd2484

Bart Trojanowski

unread,
Mar 27, 2009, 10:21:09 PM3/27/09
to Donald Ephraim Curtis, wmii...@googlegroups.com
* Donald Ephraim Curtis <dcu...@cs.uiowa.edu> [090318 01:13]:

> So I am proposing two options:
<snip>

> 2) use .wmii-lua always everywhere.

I have found a way to do thing relatively cleanly.

If you pass CONFVERSION=lua to make install in the wmii project it will
install a wmiistartrc that will launch .wmii-lua/wmiirc

I am going to start setting that as part of the kitchen sink repo's
default install, and will be putting everything in ~/.wmii-lua as of the
next release.

This should also fix the .wmii-hg issue that comes up when you don't
build from hg.

Reply all
Reply to author
Forward
0 new messages