DSL Tips and Tricks :: Startup Configs



Here's the official (I think it is anyway) Linux boot options link:

http://www.faqs.org/docs/Linux-HOWTO/BootPrompt-HOWTO.html

Automatically Set Up Xdefaults File According To A Specified Theme

I like using console applications, even in X, so at any given time I have at least two or three aterms open and have 3 different sets of aterm defaults for various console applications.  This can be annoying when I decide i don't want to look at bright orange text on a particular day or if the current colors just look like poop with my current fluxbox theme...I have to go into .Xdefaults and manually change the foreground and cursor in all three.  For a while I was using symlinks to multiple .Xdefaults files, changing the link when i wanted to change the color scheme.  However, this means having to edit every Xdefaults file whenever i want to add or edit an application.  So what I did was put the contents of .Xdefaults into .xinitrc, and have it automatically generated each time i start X.  It looks in a file called .xtheme for the name of a theme, and writes $HOME/.Xdefaults according to what it finds.  Now when i want to change the term colors I just do
"echo [themename] > .xtheme"
and then startx.  The .Xdefaults file is built fresh and all of my terms are loaded with the appropriate color.  If there is no .xtheme file it will use a grayscale theme.
This is a simplified version of what I added to .xinitrc:
Code Sample
THEME=`cat ./.xtheme`

case $THEME in
tan)
BGCOLOR=black
FGCOLOR=tan
CURSORCOLOR=sienna
;;
fire)
BGCOLOR=black
FGCOLOR=orange1
CURSORCOLOR=red4
;;
*)
BGCOLOR=black
FGCOLOR=gray90
CURSORCOLOR=gray60
;;
esac

# put Xdefaults stuff here
cat << EOF > $HOME/.Xdefaults
! THIS FILE IS AUTOMATICALLY GENERATED BY .xinitrc
! EACH TIME X STARTS. DON'T BOTHER EDITING IT.

! DEFAULT ATERM
aterm*visualBell:true
aterm*background:$BGCOLOR
aterm*foreground:$FGCOLOR
aterm*cursorColor:$CURSORCOLOR
aterm*transparent:true
aterm*shading:50
aterm*font:fixed
aterm*saveLines:1000
aterm*colorMode:true
aterm*borderWidth:0
aterm*truetintingType:true
aterm*fading:80
aterm*geometry:120x50+150+42
aterm*scrollBar:False
aterm*termName:xterm

! other terminals, symlinks to aterm
! SMALL ATERM (link name: terminal)
terminal*geometry:80x24+0-32
terminal*font: fixed
terminal*transparent:true
terminal*shading:50
terminal*fading:80
terminal*scrollBar:False
aterm*background:$BGCOLOR
terminal*foreground: $FGCOLOR
terminal*cursorColor:$CURSORCOLOR

! WIDE ATERM (link name: mc-term)
mc-term*geometry:170x30+0+0
mc-term*font: fixed
mc-term*transparent:true
mc-term*shading:50
mc-term*fading:80
mc-term*scrollBar:False
aterm*background:$BGCOLOR
mc-term*foreground: $FGCOLOR
mc-term*cursorColor:$CURSORCOLOR
EOF


Don't use this exactly as is...it will overwrite your .Xdefaults file with its own.

This can of course be expanded to make quick changes to other X applications and changes not relating just to colors, but this is just the main idea here.

One feature i added as an afterthought (not sure how useful it is) is that it looks for the .xtheme file in the current directory, so you can have a different theme depending on where you are when you startx.

GUI Desktop Chooser

Here's a little flua script that will present you with a list of desktops from which to choose.  It has fluxbox and jwm in it, but more can be added as a line-separated list called $HOME/.desktops.lst (the list overwrites the built-in list, so jwm and fluxbox need to be included in that file as well, at least for now). It works with the default .xinitrc in DSL2.1.

To use it, add the path to the script to the top of .xinitrc, before the .desktop file is checked.  

IMPORTANT:
1) Do not add '&' after the command in .xinitrc because it won't work if you allow .xinitrc to continue while the script is loaded.
2) If you add any window managers to .desktops.lst, you will need to include them in the 'case' command in .xinitrc as well.
3) The script will currently run every time you start X, which means that if you switch from one desktop to another using the window manager's menu, you'll still get the GUI chooser. I just made this as a toy, to see if there is any interest in something more complex.

Code Sample
#!/bin/flua
------------------------------------------------------------------------
-- desktop_chooser.flua
-- simple thing to let you pick a desktop as X loads
-- mikshaw 2006
-- Changelog (yyyy-mm-dd)
--  2006-01-03 First version
------------------------------------------------------------------------

execute("xsri --color2=brown --color=black")
dofile("/etc/init.d/functions.lua")
UseIcons = getOption(getenv("HOME").."/.desktop","icons")
Default_WM = getOption(getenv("HOME").."/.desktop","wm")
rcfile = getenv("HOME").."/.desktops.lst"
ww = 160
wh = 120
w_main = Window{ww,wh,"desktop_chooser"}
chooser = Hold_Browser{0,0,ww,wh-20}
listfile = openfile(rcfile,"r")
if listfile then
chooser:load(rcfile)
else
chooser:add("fluxbox")
chooser:add("jwm")
end
for whichwm = 1,chooser.size do
if Default_WM == chooser:text(whichwm) then
active_WM = whichwm
break
else
active_WM = 1
end
end
chooser:select(active_WM)
doit = Return_Button{0,wh-20,ww,20,"continue";box=Boxtype.flat}
function doit.callback()
if chooser.value > 0 then
execute("echo \"wm: "..chooser:text(chooser.value).."\" > $HOME/.desktop")
if UseIcons then execute("echo \"icons: "..UseIcons.."\" >> $HOME/.desktop") end
exit(0)
end
end
w_main:show()

Mikshaw, it's a good idea! A lot of other distros have some kind of chooser on the login screen, which DSL does not have. Maybe you could put the security log-ins for root and dsluser on the same screen as the desktop chooser instead of having to enter it during boot?
That's a pretty good idea, but it wouldn't be very secure as part of this script.  This script is not run during boot, and can be bypassed by pressing Esc.  Since you're already logged in as dsl, and X has already been started, you are sent directly to the active desktop as usual.

If you want a gui run during the boot process, the best you'll be able to do is have a whiptail script, run from /opt/bootlocal.sh or /cdrom/KNOPPIX/knoppix.sh unless you want to remaster the KNOPPIX file

Next Page...
original here.