Introduce the i3-sensible-{pager,editor,terminal} scripts
The former two provide fallbacks in case $PAGER or $EDITOR is not set (which might be more common than you think, because they have to be set in ~/.xsession, not in the shell configuration!) while the latter tries to launch a terminal emulator. The scripts are most prominently used in i3-nagbar, which alerts the user when the configuration is broken for some reason. Also, i3-sensible-terminal is used in the default configuration. This commit does not rely on the shell supporting ${PAGER:-less} anymore, which is not the case for 'fish'.
This commit is contained in:
parent
1675499f15
commit
6420b2b102
3
Makefile
3
Makefile
@ -80,6 +80,9 @@ install: all
|
||||
$(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
|
||||
$(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
|
||||
$(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
|
||||
$(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
|
||||
$(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
|
||||
$(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
|
||||
test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
|
||||
test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
|
||||
$(INSTALL) -m 0644 i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome
|
||||
|
@ -10,15 +10,21 @@ packages for them.
|
||||
Please make sure the manpage for i3 will be properly created and installed
|
||||
in your package.
|
||||
|
||||
Also please provide the path to a suitable terminal emulator which is installed
|
||||
as a dependency of your package (e.g. urxvt). On systems which have a special
|
||||
commend to launch the best available terminal emulator, please use this one
|
||||
(e.g. x-terminal-emulator on debian).
|
||||
Please check the i3-sensible-{editor,pager,terminal} scripts and modify them if
|
||||
necessary. The former two provide fallbacks in case $PAGER or $EDITOR is not
|
||||
set (which might be more common than you think, because they have to be set in
|
||||
~/.xsession, not in the shell configuration!) while the latter tries to launch
|
||||
a terminal emulator. The scripts are most prominently used in i3-nagbar, which
|
||||
alerts the user when the configuration is broken for some reason. Also,
|
||||
i3-sensible-terminal is used in the default configuration.
|
||||
|
||||
On debian, this looks like this:
|
||||
If your distribution has a mechanism to get the preferred terminal, such as the
|
||||
x-terminal-emulator symlink in Debian, please use it in i3-sensible-terminal.
|
||||
|
||||
On debian, compilation and installing the manpages looks like this:
|
||||
|
||||
# Compilation
|
||||
$(MAKE) TERM_EMU=x-terminal-emulator
|
||||
$(MAKE)
|
||||
$(MAKE) -C man
|
||||
|
||||
# Installation
|
||||
|
@ -12,7 +12,6 @@ ifndef SYSCONFDIR
|
||||
SYSCONFDIR=$(PREFIX)/etc
|
||||
endif
|
||||
endif
|
||||
TERM_EMU=xterm
|
||||
# The escaping is absurd, but we need to escape for shell, sed, make, define
|
||||
GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch $(shell [ -f $(TOPDIR)/.git/HEAD ] && sed 's/ref: refs\/heads\/\(.*\)/\\\\\\"\1\\\\\\"/g' $(TOPDIR)/.git/HEAD || echo 'unknown'))"
|
||||
VERSION:=$(shell git describe --tags --abbrev=0)
|
||||
|
14
i3-sensible-editor
Executable file
14
i3-sensible-editor
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# This script tries to exec an editor by trying some known editors if $EDITOR is
|
||||
# not set.
|
||||
#
|
||||
# Distributions/packagers can enhance this script with a
|
||||
# distribution-specific mechanism to find the preferred pager.
|
||||
which $VISUAL >/dev/null && exec $VISUAL "$@"
|
||||
which $EDITOR >/dev/null && exec $EDITOR "$@"
|
||||
|
||||
# Hopefully one of these is installed (no flamewars about preference please!):
|
||||
which nano >/dev/null && exec nano "$@"
|
||||
which vim >/dev/null && exec vim "$@"
|
||||
which vi >/dev/null && exec vi "$@"
|
||||
which emacs >/dev/null && exec emacs "$@"
|
15
i3-sensible-pager
Executable file
15
i3-sensible-pager
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# This script tries to exec a pager by trying some known pagers if $PAGER is
|
||||
# not set.
|
||||
#
|
||||
# Distributions/packagers can enhance this script with a
|
||||
# distribution-specific mechanism to find the preferred pager.
|
||||
which $PAGER >/dev/null && exec $PAGER "$@"
|
||||
|
||||
# Hopefully one of these is installed:
|
||||
which most >/dev/null && exec most "$@"
|
||||
which less >/dev/null && exec less "$@"
|
||||
# we don't use 'more' because it will exit if the file is 'too short'
|
||||
|
||||
# If no pager is installed, try an editor
|
||||
exec i3-sensible-editor "$@"
|
15
i3-sensible-terminal
Executable file
15
i3-sensible-terminal
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# This script tries to exec a terminal emulator by trying some known terminal
|
||||
# emulators.
|
||||
#
|
||||
# Distributions/packagers should enhance this script with a
|
||||
# distribution-specific mechanism to find the preferred terminal emulator. On
|
||||
# Debian, there is the x-terminal-emulator symlink for example.
|
||||
# Please don't touch the first line, though:
|
||||
which $TERMINAL >/dev/null && exec $TERMINAL "$@"
|
||||
|
||||
# Hopefully one of these is installed:
|
||||
which xterm >/dev/null && exec xterm "$@"
|
||||
which urxvt >/dev/null && exec urxvt "$@"
|
||||
which rxvt >/dev/null && exec rxvt "$@"
|
||||
which roxterm >/dev/null && exec roxterm "$@"
|
@ -16,7 +16,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||
floating_modifier Mod1
|
||||
|
||||
# start a terminal
|
||||
bindsym Mod1+Return exec urxvt
|
||||
bindsym Mod1+Return exec i3-sensible-terminal
|
||||
|
||||
# kill focused window
|
||||
bindsym Mod1+Shift+q kill
|
||||
|
@ -17,7 +17,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||
floating_modifier $mod
|
||||
|
||||
# start a terminal
|
||||
bindcode $mod+36 exec urxvt
|
||||
bindcode $mod+36 exec i3-sensible-terminal
|
||||
|
||||
# kill focused window
|
||||
bindcode $mod+Shift+24 kill
|
||||
|
@ -276,9 +276,9 @@ static void start_configerror_nagbar(const char *config_path) {
|
||||
if (configerror_pid == 0) {
|
||||
char *editaction,
|
||||
*pageraction;
|
||||
if (asprintf(&editaction, TERM_EMU " -e sh -c \"${EDITOR:-vi} \"%s\" && i3-msg reload\"", config_path) == -1)
|
||||
if (asprintf(&editaction, "i3-sensible-terminal -e sh -c \"i3-sensible-editor \\\"%s\\\" && i3-msg reload\"", config_path) == -1)
|
||||
exit(1);
|
||||
if (asprintf(&pageraction, TERM_EMU " -e sh -c \"${PAGER:-less} \"%s\"\"", errorfilename) == -1)
|
||||
if (asprintf(&pageraction, "i3-sensible-terminal -e i3-sensible-pager \"%s\"", errorfilename) == -1)
|
||||
exit(1);
|
||||
char *argv[] = {
|
||||
NULL, /* will be replaced by the executable path */
|
||||
|
Loading…
Reference in New Issue
Block a user