Sucess with dual monitors

Matthew Kuiken matt.kuiken at verizon.net
Thu Jun 22 06:10:02 UTC 2006


Erik Christiansen wrote:
> On Tue, Jun 20, 2006 at 10:52:50PM -0700, Matthew Kuiken wrote:
>   
>> if [ $# -lt 1 ]; then
>> 	echo
>> 	echo "call with 1 for single monitor, 2 for multimonitor."
>> 	exit -1
>> fi 
>>
>> if [ $1 = "2" ]; then
>> 	sudo cp /etc/X11/xorg.conf.multimonitor /etc/X11/xorg.conf
>> 	exit 2
>> elif [ $1 = "1" ]; then
>> 	sudo cp /etc/X11/xorg.conf.singlemonitor /etc/X11/xorg.conf
>> 	exit 1
>> else
>> 	echo "call with 1 for single monitor, 2 for multimonitor."
>> 	exit -2
>> fi
>>     
>
> Matthew,
>
>    That's great for a first attempt. :-)
>
> One small convenience hint:
>
> msg=""call with 1 for single monitor, 2 for multimonitor."
>
> Then in two places:
>
> echo $msg
>
> This avoids the subsequent maintenance hassle of changing one, but
> forgetting the other.
>
> I don't know whether the following offers anything that would appeal:
>
> cmd=${0##*/}                              # Command's basename
> msg="\n\tUsage: $cmd [1|2]\n\t\t1 = single monitor\n\t\t2 = multimonitor"
>
> That's all a matter of taste, except I find that separation by a blank
> line has a highlighting effect, and several lines of output jangle my
> optic nerves sufficiently to actually stimulate reading. (Your eyesight
> and attention may be better than mine. :-)
>   

Erik,

Thanks for the tips. New script attached. :)

I liked the use of message and the command being placed in the Usage: 
block, so I used that structure.

One minor detail you forgot to mention, that I will add here, in order 
for 'echo' to evaluate the newline and tab escapes it needs to be passed 
the -e parameter. Otherwise, everything you mentioned worked like a charm.

The output now looks like this:
myprompt$ ./multiMonitorSwitch

Usage: multiMonitorSwitch [1|2]
1 = single monitor
2 = multimonitor

myprompt$

I added an extra newline, as I like it being separated by a little bit 
from the new prompt as well. I added a bit of feedback to the other 
options as well. :)

The only thing in your email that throws me for a loop is the 
'cmd=${0##*/}'. I assume this is some kind of regular expression syntax? 
As an embedded 'C' programmer, I haven't been exposed to this kind of 
construct before.

Thanks,
-Matt

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: multiMonitorSwitch
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20060621/61004298/attachment.ksh>


More information about the ubuntu-users mailing list