chiark / gitweb /
xinitrc and friends: Embed prompt-and-run functionality in xinitrc.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 14 Dec 2008 18:42:25 +0000 (18:42 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 14 Dec 2008 19:02:09 +0000 (19:02 +0000)
The prompt-and-run functionality used to be in xrun.  Unfortunately,
that runs programs from the context of the window manager (assuming you
started it from M5-F9 or whatever).  We can do better, and start the
program from the context of the xinitrc script, which we can change more
readily.  It seems easiest to simply scrap xrun and embed the
functionality directly into the xinitrc.

As a bonus, I've also added (and bound to M5-F10) a popup for submitting
commands to the xinitrc itself, and provided a script xinitcmd for doing
the same from the command line (though this is less useful).

e16-bindings
setup
xinitcmd [new file with mode: 0755]
xinitrc
xrun [deleted file]

index b4c221b322c365efa5f30e64863985ab86be61dc..afd2fc84f9783280e1c7b316f4f4c32ae8acddef 100644 (file)
@@ -34,7 +34,8 @@ KeyDown   S5       Up area move 0 -1
 KeyDown   S5     Left area move -1 0
 KeyDown   S5    Right area move 1 0
 KeyDown    5       F8 exec xatom set XINIT_COMMAND :terminal
-KeyDown    5       F9 exec xrun
+KeyDown    5       F9 exec xatom set XINIT_COMMAND :ask-run
+KeyDown           5      F10 exec xatom set XINIT_COMMAND :ask-command
 KeyDown    5      F12 exec xshutdown
 KeyDown    5      Tab focus next
 KeyDown   C5       Up wop * raise
diff --git a/setup b/setup
index e2ef334b027445b2362d1a0906313fbca3a5e504..8331ea1a6f2ef1a4f9fc58c2913ad37bdf6c4500 100755 (executable)
--- a/setup
+++ b/setup
@@ -195,7 +195,7 @@ scripts="
   svnwrap
   hyperspec"
 [ "$xstuff" ] && scripts="$scripts
-  xrun
+  xinitcmd
   xshutdown"
 echo "Installing scripts..."
 mkdir -p $HOME$sub/bin
diff --git a/xinitcmd b/xinitcmd
new file mode 100755 (executable)
index 0000000..2bac08e
--- /dev/null
+++ b/xinitcmd
@@ -0,0 +1,2 @@
+#! /bin/sh
+exec xatom set XINIT_COMMAND "$*"
diff --git a/xinitrc b/xinitrc
index 1d3a83cc87e4296c4afc4d6e6c52d0b2bb994b4f..1de812bef95346d8388bef43c337cb813a3f16ba 100755 (executable)
--- a/xinitrc
+++ b/xinitrc
@@ -241,6 +241,15 @@ start-xterms () {
   done
 }
 
+###--------------------------------------------------------------------------
+### Requesters.
+
+req () {
+  declare title=$1 hist=$2; shift 2
+  cmd=$(xgetline -t "$title" -p "Command:" -Hl "$HOME/$hist") &&
+  exec "$@" "$cmd"
+}
+
 ###--------------------------------------------------------------------------
 ### Final waiting.
 
@@ -258,6 +267,7 @@ xwait () {
        xmsg -I -t "xinitrc help" -d "xinitrc commands" - <<EOF &
 :help
 :emacs :xterms :window-manager :clients
+:ask-run :ask-command
 :init
 :terminal
 ! SHELL-COMMAND
@@ -277,6 +287,12 @@ EOF
        info "restarting xinitrc"
        exec "$0" wait nostart
        ;;
+      :ask-run)
+       req "Shell command" .cmd.hist xcatch -FMiscFixed6x13 -- sh -c&
+       ;;
+      :ask-command)
+       req "xinit command" .xinit.hist xatom set XINIT_COMMAND$atomtag&
+       ;;
       :*)
        xmsg -E -t "xinitrc error" "Unknown command \`$line'" &
        ;;
diff --git a/xrun b/xrun
deleted file mode 100755 (executable)
index 7562b04..0000000
--- a/xrun
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-cmd=`xgetline -t "Shell command" -p "Command:" -Hl $HOME/.cmd.hist` &&
-  exec xcatch -- sh -c "$cmd"