Numerous changes and a restructure of .xinitrc to allow .vnc/xstartup to piggy back off of it

and offer a window manager selection dialog for remote/nested sessions

.vnc/xstartup:
  * runs pekwm and a xdialog to choose a wm; then runs "$HOME/.xinitrc wm-name remote" where
    wm-name is a lower-case window manager name (corresponding to a exectuable in $PATH)
  * see TODO at the head of the document for things to be completed
  * ISSUE: xmonad is a binary executable so there is no way to pass it a special configuration
    for a single monitor setup (for a remote session). Instead there should be a single-head
    xmonad compiled to run on remote sessions; the question is how?
.xinitrc:
  * massively restructured and now has a slightly different usage (see head of document)
  * still supports being run without command-line parameters and by slim (passed one cl parameter
    being the window manager (again in lower case and corresponding to a executable in $PATH)
.xmonad/xmonad.hs:
  * added a new manage hook for opennx
  * added a new floating manage hook doMaxFloat (thanks to OODavo) which can float windows
    that request a size smaller then the area their widgets span

Signed-off-by: Collin Doering <rekahsoft@gmail.com>
This commit is contained in:
Collin J. Doering 2012-07-12 03:25:55 -04:00 committed by Collin J. Doering
parent bd0592baac
commit bc065dda7a
3 changed files with 176 additions and 48 deletions

67
.vnc/xstartup Executable file
View File

@ -0,0 +1,67 @@
#!/bin/sh
# (C) Copyright Collin Doering @!@YEAR@!@
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# File: .vnc/xstartup
# Author: Collin J. Doering <rekahsoft@gmail.com>
# Date: Jul 12, 2012
# Description: Acts as a window-manager selector for vnc/freenx sessions
# TODO: - use retval in the case that Xdialog fails to display some message/log
# - remove use of retval for window close and cancel button as they're disabled
# - support a nicer way to add wm's to the radiolist
# - a custom pekwm config so that there are no clicky menus and such
# Set desktop default size
xrandr --output default --mode 640x480
# Start pekwm and keep its pid
pekwm &
PEKWM_PID=$!
# Offer a Xdialog session selector
Xdialog --title "Session Selection" \
--no-cancel \
--no-close \
--radiolist "Choose a session to run:" 25 112 5 \
"XMonad" "a dynamically tiling X11 window manager" off \
"OpenBox" "a highly configurable, next generation WM with extensive standards support" off \
"PekWM" "a window manager that once up on a time was based on the aewm++ window manager" off \
"Awesome" "a highly configurable, next generation framework window manager for X" off \
"StumpWM" "a tiling, keyboard driven X11 Window Manager written entirely in Common Lisp" ON 2>/tmp/wmlist.tmp.$$
# Retain the return value of Xdialog and its choices saved in /tmp/wmlist.tmp.pid where pid is the pid of this shell
retval=$?
choice=`cat /tmp/wmlist.tmp.$$ | tr '[A-Z]' '[a-z]'`
# Remove the temporary file containing Xdialogs choices
rm -f /tmp/wmlist.tmp.$$
# Stop pekwm
kill $PEKWM_PID
# Run a session depending on the return value and choice from Xdialog
case $retval in
0)
exec $HOME/.xinitrc $choice remote
;;
# 1)
# echo "Cancel pressed."
# ;;
# 255)
# echo "Box closed."
# ;;
esac

111
.xinitrc Normal file → Executable file
View File

@ -6,48 +6,79 @@
# GENERIC # # GENERIC #
# Set the default curson used by xmonad # Usage: .xinitrc [window-manager] [session-type]
# where: window-manager is one of '(xmonad openbox stumpwm awesome pekwm)
# session-type is either "" or "remote"
# Set the default curson used by all WM's
xsetroot -cursor_name left_ptr xsetroot -cursor_name left_ptr
# Setup monitors # Initialize a local desktop session (run generic helper applications)
xrandr --output DVI-I-1 --auto --output DVI-I-2 --auto --left-of DVI-I-1 function init_local_session() {
# Setup monitors
xrandr --output DVI-I-1 --auto --output DVI-I-2 --auto --left-of DVI-I-1
# Start xscreensaver
xscreensaver -no-splash &
# Set a desktop background
nitrogen --restore &
# Start xscreensaver # Have mouse pointer hide after 5 seconds
xscreensaver -no-splash & unclutter &
# Setup system tray *DISABLED* :: whats the point of a systray if no apps use it?
#trayer --monitor 1 --edge top --align right --expand true --width 4 --height 2 --transparent true --tint 0x000000 &
# Use xbindkeys to bind media keys etc..
xbindkeys &
# Start pulseaudio
#start-pulseaudio-x11 &
# Start-up applications
#parcellite &
emacs --daemon &
urxvtd --quiet &
xcompmgr &
# Create variable GENERAL_SCREEN which is the pid of a screen called "general"
export GENERAL_SCREEN=`screen -ls | grep general | cut -f1 -d'.' | sed 's/\W//g'`
# Check to see if a general screen is already running
if [ "x$GENERAL_SCREEN" == "x" ]; then
screen -dmS general &
fi
# Set the default wm to xmonad
DEFAULT_WM=xmonad
}
# Set a desktop background # Initialize a remote desktop session (run generic helper applications)
nitrogen --restore & function init_remote_session() {
# Set desktop background
feh --bg-scale ~/.wallback/Cocaine_Wallpaper_II_by_mdornfeld.png &
# Set the default wm to xmonad
DEFAULT_WM=stumpwm
}
# Have mouse pointer hide after 5 seconds # Check the second cl parameter which denotes the session-type (E.g. remote, local)
unclutter & case $2 in
# Remote session
remote)
init_remote_session
break
;;
# Local session or unspecified
*)
init_local_session
;;
esac
# Setup system tray *DISABLED* :: whats the point of a systray if no apps use it? # Check the first cl parameter which denotes the window-manager to use
#trayer --monitor 1 --edge top --align right --expand true --width 4 --height 2 --transparent true --tint 0x000000 & # Notice: in each case expression below "exec app" hands over execution to some app thus
# ceasing execution in this script so no "break" is required
# Use xbindkeys to bind media keys etc..
xbindkeys &
# Start pulseaudio
#start-pulseaudio-x11 &
# Start-up applications
parcellite &
emacs --daemon &
urxvtd --quiet &
xcompmgr &
# Create variable GENERAL_SCREEN which is the pid of a screen called "general"
export GENERAL_SCREEN=`screen -ls | grep general | cut -f1 -d'.' | sed 's/\W//g'`
# Check to see if a general screen is already running
if [ "x$GENERAL_SCREEN" == "x" ]; then
screen -dmS general &
fi
# Set the default session to xmonad
DEFAULT_SESSION=xmonad
# Check the given parameter from slim to determine the session being requested by slim/the user
case $1 in case $1 in
xmonad) xmonad)
exec xmonad exec xmonad
@ -58,7 +89,13 @@ case $1 in
stumpwm) stumpwm)
exec stumpwm exec stumpwm
;; ;;
awesome)
exec awesome
;;
pekwm)
exec pekwm
;;
*) *)
exec $DEFAULT_SESSION exec $DEFAULT_WM
;; ;;
esac esac

View File

@ -227,7 +227,7 @@ myGenericKeys =
, ((modm .|. controlMask, xK_e), spawn "emacsclient -c") , ((modm .|. controlMask, xK_e), spawn "emacsclient -c")
-- Launch tuxcmd -- Launch tuxcmd
, ((modm .|. controlMask, xK_t), spawn "tucmd") --, ((modm .|. controlMask, xK_t), spawn "tuxcmd")
-- Launch zathura -- Launch zathura
, ((modm .|. controlMask, xK_z), spawn "zathura") , ((modm .|. controlMask, xK_z), spawn "zathura")
@ -245,11 +245,14 @@ myGenericKeys =
, ((modm .|. controlMask, xK_1), namedScratchpadAction scratchpads "screen-terminal") , ((modm .|. controlMask, xK_1), namedScratchpadAction scratchpads "screen-terminal")
-- Launch a maintainance scratchpad -- Launch a maintainance scratchpad
, ((modm .|. controlMask, xK_2), namedScratchpadAction scratchpads "maintainance-terminal") , ((modm .|. controlMask, xK_2), namedScratchpadAction scratchpads "maintenance-terminal")
-- Launch MC scratchpad -- Launch MC scratchpad
, ((modm .|. controlMask, xK_3), namedScratchpadAction scratchpads "mc-scratch") , ((modm .|. controlMask, xK_3), namedScratchpadAction scratchpads "mc-scratch")
-- Launch MC scratchpad
, ((modm .|. controlMask, xK_4), namedScratchpadAction scratchpads "pavucontrol-scratch")
-- Select window from dmenu and go to the workspace its on -- Select window from dmenu and go to the workspace its on
, ((modm .|. shiftMask, xK_g), gotoMenuArgs ["-i","-nb", "#040404","-nf","#00FFFF","-sf","#ffa0ff","-sb","#000000"]) , ((modm .|. shiftMask, xK_g), gotoMenuArgs ["-i","-nb", "#040404","-nf","#00FFFF","-sf","#ffa0ff","-sb","#000000"])
@ -343,7 +346,18 @@ myLayout = smartBorders . avoidStruts $
-- Percent of screen to increment by when resizing panes -- Percent of screen to increment by when resizing panes
delta = 3/100 delta = 3/100
------------------------------------------------------------------------
-- Thanks to OODavo from #haskell on freenode; used for applications
-- that do not doFullFloat well (they request a window size smaller
-- then the widgets they contain)
maxFloat = flip W.float $ rectWithBorder 0.05
where rectWithBorder x = let lt = x
wh = 1 - 2*x
in W.RationalRect lt lt wh wh
doMaxFloat = ask >>= doF . maxFloat
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Window rules: -- Window rules:
@ -365,35 +379,39 @@ myManageHook = composeAll
-- , title =? "DOOM 3" --> doIgnore -- , title =? "DOOM 3" --> doIgnore
, resource =? "Qt-subapplication" <&&> title /=? "Oracle VM VirtualBox Manager" --> doFloat , resource =? "Qt-subapplication" <&&> title /=? "Oracle VM VirtualBox Manager" --> doFloat
, resource =? "vncviewer" --> doCenterFloat , resource =? "vncviewer" --> doCenterFloat
, resource =? "opennx" --> doMaxFloat
, resource =? "Steam.exe" --> doCenterFloat , resource =? "Steam.exe" --> doCenterFloat
, title =? "Xnest" --> doCenterFloat , title =? "Xnest" --> doCenterFloat
-- , resource =? "hl2.exe" --> doCenterFloat -- , resource =? "hl2.exe" --> doCenterFloat
, isFullscreen --> (doF W.focusDown <+> doFullFloat) , isFullscreen --> (doF W.focusDown <+> doFullFloat)
, resource =? "desktop_window" --> doIgnore ] <+> namedScratchpadManageHook scratchpads <+> manageDocks , resource =? "desktop_window" --> doIgnore ] <+> namedScratchpadManageHook scratchpads <+> manageDocks
-- NamedScratchPad Hook -- NamedScratchPad Hook
scratchpads = [ NS "emacs-scratch" spawnEmacsScratch findEmacsScratch manageEmacsScratch scratchpads = [ NS "emacs-scratch" spawnEmacsScratch findEmacsScratch manageEmacsScratch
, NS "maintainance-terminal" spawnMaintainanceTerminal findMaintainanceTerminal manageMaintainanceTerminal , NS "maintenance-terminal" spawnMaintenanceTerminal findMaintenanceTerminal manageMaintenanceTerminal
, NS "screen-terminal" spawnScreenTerminal findScreenTerminal manageScreenTerminal , NS "screen-terminal" spawnScreenTerminal findScreenTerminal manageScreenTerminal
, NS "mc-scratch" spawnMcScratch findMcScratch manageMcScratch] , NS "mc-scratch" spawnMcScratch findMcScratch manageMcScratch
, NS "pavucontrol-scratch" spawnPavucontrolScratch findPavucontrolScratch managePavucontrolScratch]
where where
findEmacsScratch = resource =? "emacs-scratch" findEmacsScratch = resource =? "emacs-scratch"
findMaintainanceTerminal = resource =? "scratchpad" findMaintenanceTerminal = resource =? "scratchpad"
findScreenTerminal = resource =? "screen-scratch" findScreenTerminal = resource =? "screen-scratch"
findMcScratch = resource =? "mc-scratch" findMcScratch = resource =? "mc-scratch"
findPavucontrolScratch = resource =? "pavucontrol"
spawnEmacsScratch = myTerminal ++ " -name emacs-scratch -pe -tabbedex -e emacsclient -nw" spawnEmacsScratch = myTerminal ++ " -name emacs-scratch -pe -tabbedex -e emacsclient -nw"
spawnMaintainanceTerminal = myTerminal ++ " -name scratchpad" spawnMaintenanceTerminal = myTerminal ++ " -name scratchpad"
spawnScreenTerminal = myTerminal ++ " -name screen-scratch -bg black" spawnScreenTerminal = myTerminal ++ " -name screen-scratch -bg black"
spawnMcScratch = myTerminal ++ " -name mc-scratch -pe -tabbedex -e mc" spawnMcScratch = myTerminal ++ " -name mc-scratch -pe -tabbedex -e mc"
spawnPavucontrolScratch = "pavucontrol"
manageEmacsScratch = customFloating $ W.RationalRect l t w h manageEmacsScratch = customFloating $ W.RationalRect l t w h
where where
h = 0.65 -- terminal height (%) h = 0.65 -- terminal height (%)
w = 0.55 -- terminal width (%) w = 0.55 -- terminal width (%)
t = 1 - h -- distance from top edge (%) t = 1 - h -- distance from top edge (%)
l = 1 - w -- distance from left edge (%) l = 1 - w -- distance from left edge (%)
manageMaintainanceTerminal = customFloating $ W.RationalRect l t w h manageMaintenanceTerminal = customFloating $ W.RationalRect l t w h
where where
h = 0.33 -- terminal height (%) h = 0.33 -- terminal height (%)
w = 1 -- terminal width (%) w = 1 -- terminal width (%)
@ -411,6 +429,12 @@ scratchpads = [ NS "emacs-scratch" spawnEmacsScratch findEmacsScratch manageEmac
w = 0.55 -- terminal width (%) w = 0.55 -- terminal width (%)
t = 1 - h -- distance from top edge (%) t = 1 - h -- distance from top edge (%)
l = 1 - w -- distance from left edge (%) l = 1 - w -- distance from left edge (%)
managePavucontrolScratch = customFloating $ W.RationalRect l t w h
where
h = 0.80 -- terminal height (%)
w = 0.55 -- terminal width (%)
t = 1 - h -- distance from top edge (%)
l = 1 - w -- distance from left edge (%)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Event handling -- Event handling