X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/7f903e21a9d57c6e504c3bbf55dc5b31c041928c..807c317e99426f8379fc55fc4d4bc98e67ec0f41:/dot/xinitrc diff --git a/dot/xinitrc b/dot/xinitrc index 7f6d415..89105c1 100755 --- a/dot/xinitrc +++ b/dot/xinitrc @@ -108,7 +108,11 @@ fi ### Iniitial settings. ## Assume X sessions are secure. -export __mdw_sechost="`hostname`" +export __mdw_sechost="$(hostname)" + +## Tell things that XFCE is in charge. This is the most desktoppy thing that +## I run, so it's not entirely wrong. +: ${XDG_CURRENT_DESKTOP=XFCE}; export XDG_CURRENT_DESKTOP ## Obtain the screen dimensions. case ",$XWIDTH,$XHEIGHT," in @@ -116,7 +120,7 @@ case ",$XWIDTH,$XHEIGHT," in esac case ",$XNSCR," in ,,) - XNSCR=1 XSCR0_X=0 XSCR0_Y=0 XSCR0_WIDTH=$XWIDTH XSCR0_HEIGHT=XHEIGHT + XNSCR=1 XSCR0_X=0 XSCR0_Y=0 XSCR0_WIDTH=$XWIDTH XSCR0_HEIGHT=$XHEIGHT ;; esac i=0; while (( i < XNSCR )); do @@ -216,11 +220,30 @@ start-clients () { ### Main screen layout. ## Choose appropriate clients. -emacs=$(pick_program emacs emacs23 emacs24 emacs22 emacs21 emacs) +emacs=$(pick_program emacs \ + emacs24-lucid emacs23-lucid emacs24 emacs23 emacs22 emacs21 \ + emacs-lucid emacs) term=$(pick_program terminal pterm Eterm xterm) +## If we fell back to an unversioned Emacs binary, then figure out what +## version it actually is. +case $emacs in + emacs | emacs-lucid) + set -- $($emacs --version | head -n1) + e_ver=emacs${3%%.*}${emacs#emacs} + ;; + *) + e_ver=$emacs + ;; +esac +info emacs-version = $e_ver + ## Emacs window measurements. ## +## e_colsz = width of a column in characters (from `emacs-width' metaconfig) +## e_charwd = width of a character in pixels (assume `6x13') +## e_colextra = additional per-column overhead in pixels +## e_colextrachars = additional per-column overhead in character units ## e_colwd = basic width of a column in pixels ## e_hextra = extra horizontal width in pixels ## Width of an N-column Emacs frame in pixels will be @@ -232,23 +255,18 @@ term=$(pick_program terminal pterm Eterm xterm) ## e_lineht = height of a character line in pixels ## e_vextra = number of additional vertical cruft pixels ## So an N-line Emacs frame takes N*e_lineht + e_vextra pixels -case "$emacs" in - emacs21 | emacs) - e_colwd=492 e_hextra=34 - e_colchars=82 e_cextra=-2 - e_lineht=13 e_vextra=52 - ;; - emacs22 | emacs23) - e_colwd=492 e_hextra=8 - e_colchars=82 e_cextra=-6 - e_lineht=13 e_vextra=46 - ;; - emacs24) - e_colwd=492 e_hextra=5 - e_colchars=82 e_cextra=-6 - e_lineht=13 e_vextra=42 - ;; +e_colsz=$(mdw-conf emacs-width 77) e_charwd=6 +e_colextra=30 e_colextrachars=5 e_lineht=13 +case "$e_ver" in + emacs21 | emacs) e_hextra=34 e_cextra=-2 e_vextra=52 ;; + emacs22 | emacs23) e_hextra=8 e_cextra=-6 e_vextra=46 ;; + emacs24) e_hextra=5 e_cextra=-6 e_vextra=42 ;; + emacs23-lucid) e_hextra=7 e_cextra=-6 e_vextra=48 ;; + emacs24-lucid) e_hextra=7 e_cextra=-5 e_vextra=48 ;; + emacs26-lucid) e_hextra=5 e_cextra=-6 e_vextra=51 ;; esac +e_colwd=$(( e_colsz*e_charwd + e_colextra )) +e_colchars=$(( e_colsz + e_colextrachars )) ## Terminal window measurements. ## @@ -256,7 +274,14 @@ esac ## t_lineht, t_vextra = height parameters: if the window is N lines high, ## then it will be N*t_lineht + t_vextra pixels high case "$term" in - pterm) t_wd=504 t_lineht=13 t_vextra=23 geom=-geometry;; + pterm) + ## The pterm width differs according to whether it's linked against Gtk 2 + ## or 3. Let's find out... + case $(ldd $(command -v pterm) | grep libgtk) in + *libgtk-2* | *libgtk-x11-2*) t_wd=504 ;; + *) t_wd=503 ;; + esac + t_lineht=13 t_vextra=23 geom=-geometry;; Eterm) t_wd=504 t_lineht=13 t_vextra=23 geom=-g;; xterm) t_wd=507 t_lineht=13 t_vextra=27 geom=-geometry;; esac @@ -266,18 +291,25 @@ declare -i panelwd=64 xbound=$(( XWIDTH - panelwd )) ## Choose a width for Emacs. ## -## We'd like it to be as wide as possible, allowing for a column of xterms -## down the right hand side. However, I'd prefer a double-width Emacs to a -## single-width Emacs and xterms. If it's not going to work at all, a single -## Emacs column will have to do. Also, there's a strange thing with Emacs21 -## and the toolbar, so we add on some rows which are later mysteriously -## subtracted. - +## We're going to make a single frame of Emacs, which will be automatically +## divvied into columns; the rest of the space will be tiled with xterms. If +## we have multiple screens, then Emacs can have the first screen and we'll +## fill the rest with terminals. Otherwise, we'll try to have N columns of +## Emacs, and N - 1 columns of xterms; if that doesn't work, we'll make do +## with N - 2 columns of xterms. +## +## So, let W be the available width; let E and T be the widths of an Emacs +## column (e_colwd) and terminal (t_wd), respectively, and let E0 be the +## additive width of Emacs's existence (e_hextra). If we have more than one +## screen, then instead, let T be zero. To start out, then, we let N = 1 + +## floor((W - E - E0)/(E + T)). If W - E0 - (N + 1) E - (N - 1)*T >= 0, then +## we increase N by one. declare -i lim=XSCR0_WIDTH if (( lim > xbound )); then lim=xbound; fi -declare -i ecols=$(( (lim - t_wd - e_hextra)/e_colwd )) -if (( ecols < 2 && lim > 2*e_colwd + e_hextra )); then ecols=2 -elif (( ecols < 1 )); then ecols=1 +declare -i twd=t_wd; if (( XNSCR > 1 )); then twd=0; fi +declare -i ecols=$(( (lim - e_colwd - e_hextra)/(e_colwd + twd) + 1 )) +if (( lim - e_hextra - (ecols + 1)*e_colwd - (ecols - 1)*twd >= 0 )); then + ecols=$(( ecols + 1 )) fi declare -i \ @@ -286,7 +318,8 @@ declare -i \ start-emacs () { GDK_NATIVE_WINDOWS=1 run bgclients noip \ - $emacs -bg black -geometry ${emacsx}x${emacsy}+${XSCR0_X}+${XSCR0_Y} + $emacs -bg black -geometry ${emacsx}x${emacsy}+${XSCR0_X}+${XSCR0_Y} \ + --mdw-splashy-startup } ## Now place some xterms. @@ -408,7 +441,7 @@ EOF eval "${line#!}" ;; *) - set -- $line + eval "set -- $line" run bgclients "$@" ;; esac