newbie question on scripting

I am currently running dual monitors, but cannot get quake, wop, etc. to run dual screen. I would like to create a button on my desktop that would switch out xorg.conf files. So, the questions are:

1 - How to write the script. I have not done one before but assume it is similar to an old batch file.

copy /etc/X11/xorg.conf-dual xorg.conf ?

2 - Because it is in /etc I would assume it needs some type of sudo or su command written into it. I am not sure sudo is set up correctly on my system, because any time I try to use it, it doesn’t load the app called. I have to revert to su.

3 - How do I then link this script to an icon on the desktop?

thanks in advance, sorry if this is too basic,
idee

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Presumably you want two scripts; one to enable dual and one to disable it,
right? I’d personally just create scripts in ~/bin (/home/ab/bin where
‘ab’ is my username) and then mark them executable and call them whenever
needed by pressing Alt+F2 and then running something like 1gnomesu
enabledualorgnomesu disabledual` where ‘enabledual’ and ‘disabledual’
are the scripts placed in /home/ab/bin. Another option may be to have one
script that takes a parameter of ‘enable’ or ‘disable’ or a filename and
does the operation appropriate based on the parameter. The combinations
are probably nearly endless but how you want it depends on your
preferences. Having a clickable option on your desktop would be trivial
as well; create a launcher (right-click, Create Launcher) that points to
the script(s) and make sure you don’t need to give the script(s) any
parameters for them to work properly since this is now a GUI-ish thing
instead of a command-line thing.

Good luck.

idee wrote:
> I am currently running dual monitors, but cannot get quake, wop, etc. to
> run dual screen. I would like to create a button on my desktop that
> would switch out xorg.conf files. So, the questions are:
>
> 1 - How to write the script. I have not done one before but assume it
> is similar to an old batch file.
>
> copy /etc/X11/xorg.conf-dual xorg.conf ?
>
> 2 - Because it is in /etc I would assume it needs some type of sudo or
> su command written into it. I am not sure sudo is set up correctly on
> my system, because any time I try to use it, it doesn’t load the app
> called. I have to revert to su.
>
> 3 - How do I then link this script to an icon on the desktop?
>
>
> thanks in advance, sorry if this is too basic,
> idee
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJKEJ9xAAoJEF+XTK08PnB5bh8QAISnOe715YmU7ZhHcc5XK/fc
eVbKwddqmsbyNo+23uu4los0xNSzZxruO17aVMqaSYlUHSh1s7GSHYYdubF9M0Xu
u3oyf4mK39U6q222IW39uQCiK32/TKTV/a9d7PY1tuPyb1uP1azdLZ3xxFYM2t4T
N+ZdYNKlZ/V4XCO3VfBBs8x97CNm3K9z06Lj9NfivzSwTOK8Uhb6sclWD84cZsrC
D1Fh06KW6jag2oDQy+30RJKpHAcAVyRFn703Q9HLKojKfplPEiM5ilmh64Uav23A
AuwlMFz3F9fju00rZuV+N61SLpMXutf0JMZe8jYvvm8ntaMhb2XRYv7vTjUFkwz0
3Q4BZ/BjaEYKxtMgW996aGOQBOUkseSh6cDqSbKCkxc+R89uMNhD8YaA51ZZyVyB
1hjzz+9+IpuMM+BTq55VssXiavrutzHUte/UdVrOjcztiGu4vkd6z9HGvR2ptQ8+
8sv/pCsIbDdxmYyAOpq0WfeVJQAkn3dW9CVwDAlk9GsLTYMv42rW4DrO3Q8xvZfr
Q/sckhaJKpT/rRtjsb/dQikVhhxwoZYvo6Hna4VEkVaTFfnoT6tRX2OOw0iU5GMV
7LNmEAa60B97ANEZtd2TSYITtYJlOAyjpEUS9p4Qlu7xfBSNGl8yq80cOsIqHcbL
nf6d7G4gpotbV7jdyiTe
=bvR7
-----END PGP SIGNATURE-----

Thanks, so would the script be something like?

  sudo cp xorg-single-11.1.conf /etc/X11/xorg.conf

then to switch back (like you said)

  sudo cp xorg-dual-11.1.conf /etc/X11/xorg.conf

I am still a little fuzzy on how to get it to copy into a protected (root access) area without having to put in my root password? Is it as easy as making the ownership of the script root?

OK, all of that said, I really like your suggestion of:

“Another option may be to have one
script that takes a parameter of ‘enable’ or ‘disable’ or a filename and
does the operation appropriate based on the parameter.”

So how would I do that? Where do I start?

thanks

Rather than copying files, why not just create xorg.conf as a symlink to one or the other? Quicker and slightly safer.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Good idea.

Start here to make sudo work for you, and use symlinks instead of copying.

sudo ln -sf /etc/X11/xorg-single-11.1.conf /etc/X11/xorg.conf

or

sudo ln -sf /etc/X11/xorg-dual-11.1.conf /etc/X11/xorg.conf

Good luck.

ken yap wrote:
> Rather than copying files, why not just create xorg.conf as a symlink to
> one or the other? Quicker and slightly safer.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJKEMmxAAoJEF+XTK08PnB5lRsP/R7jDIHlnoiUyoivhq8aj20i
N7mVt/JbnT/6qgmyY3Tc171QMCVbDZ0YeN7NBg6ZfAJa7ZTi1IGWFAEjg5MggnDQ
SJxVdRtYbtkPwftXz1Ss/cfz7HQtL/67J7uDFzvS4EqS9bZef7fWAgHwJXtLmOW9
4MujF6eU3Bjxj8ywXSy2l/Rhu7Fltsv1AeItLeF6KE7blRriKfCjkYNY1aYI2cBq
wn33Y8afmMuEaDD8EwufgroBUhyxVJp7JtRyDwghV47QenPNMcRBHhWNECS+ZRv8
M6MnWmAJe9C1m1HynjlhymNiNzU+ij1uDw6C7XVNoZn+W0m/4hJKnlPIczLlwafq
1RdX2PHYX0HbelCwToBypFs7ubk9UEZildlkMBWtrl+S1vpEWKBRLAo1+g2bte6B
h++oBB5E8uselZjIsVBn56CYBDD/tjyRssxg+0PNQB1H4v8y4TNa+tCI7A9/ES6+
q8syWFS2s4ZtvgekU3EiPMVcmHPmQmmJ2E/ofhggfZLhflY005PEY4ANxHNQHOTn
cD5CUsrTtZh2JuubtOSnqhP5xXXrCaZQl6fh/usNGdi5pOe7w9D/epgWZ44wB17w
cFN2C8aEPrsAJlOFnAwd+hp9xCdp/gPTPEAduxZ9ALwvH0kGshc1d3nrPvW6dNDU
NgzioH7z+kseQdncSsKH
=Ff6+
-----END PGP SIGNATURE-----

I was used to previous versions of kde where I could right mouse click and create a desktop item. How do I do it in 4.2.1 ? Is it a add widget? which one?

You should add the folderview widget, and inside that you can add a launcher (Link to Application).

“Another option may be to have one
script that takes a parameter of ‘enable’ or ‘disable’ or a filename and
does the operation appropriate based on the parameter.”

So how would I do that? Where do I start?

thanks

Regarding that, here’s a simple example:


#!/bin/bash
# That bit up there is to tell the interpreter that
# we explicitly want to use the bash shell.
# These hashes are for commenting, much like rem or :: in batch.
#
# Example script by i-ghost.
#

if  x"$1" = x"--enable" -o x"$1" = x"-e" ] ; then
	clear
	echo "Enable X.org swap"
	exit;
fi;

# What does this first bit do?
# First of all, $1 is the first parameter on a command line.
# We will then check that variable with a simple string check.
# the 'x' before each string tells bash that we
# are comparing strings exactly whilst the '-o'
# option is basically an "or if".
#

if   x"$1" = x"--disable" -o x"$1" = x"-d" ] ; then
	clear
	echo "Disable X.org swap"
	exit;
fi;

# This second bit is exactly the same as the first,
# except we are looking for a different string, so
# we produce a different result.

if  x"$1" != x"" -o x"$2" != x"" ] ; then
	echo "Invalid option -- '$1'"
	exit;
fi;

# This final bit is placed here purposely to make bash check
# if the input was unexpected without dismissing the previous
# checks. If the input does not equal anything then
# tell the user. It may seem a bit confusing but if you read
# and check it through then it will become apparent.
# The '!=' means "not equal to"

clear
echo "Example script by i-ghost."
echo "Options:"
echo "--enable, -e] - Enables X.org swap thingy"
echo "--disable, -d] - Disables X.org swap thingy"
exit;

# If the user enters no arguments, present them with options.
# End Script.

Copy and paste this into a blank file then open it in a terminal.

I too came from the world of Windows batch and although I still script in batch, I much prefer the structure of bash. Feel free to PM me if you need any more advice.

Thanks, so, with something like this looking for the different parameters;

1 - how do I tie this to the xorg.conf files?
I assume you are thinking the symlink direction (above)?
sudo ln -sf /etc/X11/xorg-single-11.1.conf /etc/X11/xorg.conf
and
sudo ln -sf /etc/X11/xorg-dual-11.1.conf /etc/X11/xorg.conf

2 - how does it know which one is running? Create a variable that changes when the symlink is run? How would you do this?

3 - how do we switch them?

thanks, and yes, I am in over my head, but wanting to learn and get this working.

No need to maintain another variable. You can examine the filename that the symlink points to and then you know which one is active, so you just have to link it to the other one to switch.

Sorry for being so dumb, but how would I do that? Or is there a tutorial or something I could look at?

thanks

I think what Ken is saying as you’re creating a link to it you can check where the /etc/X11/xorg.conf is pointing to.

By the way sort of followed this thread, if you’re using nvidia settings can’t you use them(Suse in a vmware at the mo). Its just doing it the other way you’ll still need to reload x.

It’s just I have the ability to use nvidia-settings to configure some bits I don’t know how this is represented with a dual setup, but if you can disable it. Then you could just load the nvidia-settings from the user environment. If you try as user it should create ~/.nvidia-settings-rc. I presume ati does something similar. I can’t remember whether Suse locks out nvidia settings from the user. But I have used something similar with a game that needed the screen over brightening.

The readlink command will tell you the destination of a symlink.

Thanks,
Let me kick this around for a bit and I will get back with either more questions or a report of success.

It’s been a while, sorry there’s been a lot going on. I can finally get back to this. I was rereading and saw the note above about using the Nvidia settings without forcing a reboot. Could you please elaborate? What would I need? The Nvidia X Server Settings are available. I just opened them. Is that what you were referring to?

thanks

The Nvidia X Server Settings are available. I just opened them. Is that what you were referring to?

Yes it was now in my host distro I can use them as user, but from the looks of things this maybe wrong from my brief browse it looks like to disable a screen will need a restart of x(I was just tweaking brightness).

The other option that might work would be to startx on tty8 but this will need some managing. xorg.conf(5x) manual page I presume if you had layout/config then you could just use startx -config or startx -layout depending on the way you choose.

For example if you try startx – :1
then go to tty8 ctrl alt f8

You could then get a little more complicated and use init 4 as it isn’t being used to startx with the config you want. But you’ll have to work your way through suse’s init system.

I can’t help further sorry as for the nvidia idea sorry about that seems in this case a red herring.

Hopefully that will give you some more ideas to work with.