PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > linux.debian.user > bash, xbindkeys and dual screen
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
linux.debian.user debian-user@lists.debian.org.

bash, xbindkeys and dual screen

Réponse
 
LinkBack Outils de la discussion
Vieux 27/09/2007, 04h10   #1
Nguyen, Cuong K.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut bash, xbindkeys and dual screen

Hi all,

I have a problem - basically with some bash codes. I have dual screen
and one mouse, and I want to switch my mouse back and forth from screen
1 to screen 2 etc by pressing a keyboard. In order to do that, I did the
following:

1. install switchscreen, then by typing "switchscreen 0" or
"switchscreen 1" will switch me to Desktop 0 or 1.

2. typing "switchscreen 0" or 1 is annoying, then I create a script
/bin/switchnow like below:
########################
#!/bin/bash

case $DISPLAY in
:0.0 ) exec switchscreen 1
;;
:0.1 ) exec switchscreen 0
esac
########################
and make it executable, then now by typing just switchnow on terminal, I
will move back and forth from Desktop 0 and 1. Obviously it works

3. I install xbindkeys, find the corresponding key and create
~/.xbindkeysrc as follow
########################
# shortcut 2
"switchnow"
m:0x0 + c:118
########################

Okey, everything seems to be done now. I press the key, and from Desktop
0, I am switched to Desktop 1. But when I press the same key again,
nothing happens.

It *seems* that when xbindkeys works and executes switchnow, the value
of DISPLAY is kept unchanged to be :0.0. But in desktop 1, open terminal
and when I type "echo $DISPLAY" then I get :0.1. I guess I wrote the
script incorrectly, or did I miss something here?

I do not know programming, and do not know bash either. So please do not
blame me if I am too noob to bash .

Thanks a million,

KC.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 27/09/2007, 07h30   #2
Mumia W..
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen

On 09/26/2007 10:00 PM, Nguyen, Cuong K. wrote:
> Hi all,
>
> I have a problem - basically with some bash codes. I have dual screen
> and one mouse, and I want to switch my mouse back and forth from screen
> 1 to screen 2 etc by pressing a keyboard. In order to do that, I did the
> following:
>
> 1. install switchscreen, then by typing "switchscreen 0" or
> "switchscreen 1" will switch me to Desktop 0 or 1.
>
> 2. typing "switchscreen 0" or 1 is annoying, then I create a script
> /bin/switchnow like below:
> ########################
> #!/bin/bash
>
> case $DISPLAY in
> :0.0 ) exec switchscreen 1
> ;;
> :0.1 ) exec switchscreen 0
> esac
> ########################
> and make it executable, then now by typing just switchnow on terminal, I
> will move back and forth from Desktop 0 and 1. Obviously it works
>
> 3. I install xbindkeys, find the corresponding key and create
> ~/.xbindkeysrc as follow
> ########################
> # shortcut 2
> "switchnow"
> m:0x0 + c:118
> ########################
>
> Okey, everything seems to be done now. I press the key, and from Desktop
> 0, I am switched to Desktop 1. But when I press the same key again,
> nothing happens.
>
> It *seems* that when xbindkeys works and executes switchnow, the value
> of DISPLAY is kept unchanged to be :0.0. But in desktop 1, open terminal
> and when I type "echo $DISPLAY" then I get :0.1. I guess I wrote the
> script incorrectly, or did I miss something here?
>
> I do not know programming, and do not know bash either. So please do not
> blame me if I am too noob to bash .
>
> Thanks a million,
>
> KC.
>
>


You're probably right that the DISPLAY is always :0.0. You need another
way to toggle between 0 and 1. Try this:

#!/bin/bash
swfile=/tmp/sw-file
if [ ! -f $swfile ]; then echo 0 > $swfile ; fi
echo $(( ! `cat $swfile` )) > $swfile
echo exec switchscreen `cat $swfile`

Note that I just echo-ed the command because I don't have switchscreen
installed. The $(( ... )) syntax allows you to evaluate mathematical
expressions. Read "man bash"

HTH



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 27/09/2007, 17h50   #3
Nguyen, Cuong K.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen


> You're probably right that the DISPLAY is always :0.0. You need
> another way to toggle between 0 and 1. Try this:
>
> #!/bin/bash
> swfile=/tmp/sw-file
> if [ ! -f $swfile ]; then echo 0 > $swfile ; fi
> echo $(( ! `cat $swfile` )) > $swfile
> echo exec switchscreen `cat $swfile`
>
> Note that I just echo-ed the command because I don't have switchscreen
> installed. The $(( ... )) syntax allows you to evaluate mathematical
> expressions. Read "man bash"
>
> HTH
>

Works perfectly! Thanks HTH

KC.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 27/09/2007, 20h20   #4
Andrew Sackville-West
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen

On Thu, Sep 27, 2007 at 12:44:32PM -0400, Nguyen, Cuong K. wrote:
>
>> You're probably right that the DISPLAY is always :0.0. You need another
>> way to toggle between 0 and 1. Try this:
>>
>> #!/bin/bash
>> swfile=/tmp/sw-file
>> if [ ! -f $swfile ]; then echo 0 > $swfile ; fi
>> echo $(( ! `cat $swfile` )) > $swfile
>> echo exec switchscreen `cat $swfile`
>>
>> Note that I just echo-ed the command because I don't have switchscreen
>> installed. The $(( ... )) syntax allows you to evaluate mathematical
>> expressions. Read "man bash"
>>
>> HTH
>>

> Works perfectly! Thanks HTH


Cuong, I'm curious, running dual-screen myself, about your setup. I am
running xinerama and that combines my two screens into one large
one. The mouse flows effortlessly from one to the other. I find it
works very well with a tiling WM (wmii here) and just love it. What do
you find to be the advantages/disadvantages to have two truly separate
screens?


A

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFG/ACyaIeIEqwil4YRArKQAKCXSd3w0REamY1CkqiPuQsaNMRM7QC g0PpU
sbxto7UAXHnwnwiJjw1Tyfk=
=tuZx
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 27/09/2007, 21h10   #5
Nguyen, Cuong K.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen

On 9/27/07, Andrew Sackville-West <andrew@farwestbilliards.com> wrote:
>
> On Thu, Sep 27, 2007 at 12:44:32PM -0400, Nguyen, Cuong K. wrote:
> >
> >> You're probably right that the DISPLAY is always :0.0. You need another
> >> way to toggle between 0 and 1. Try this:
> >>
> >> #!/bin/bash
> >> swfile=/tmp/sw-file
> >> if [ ! -f $swfile ]; then echo 0 > $swfile ; fi
> >> echo $(( ! `cat $swfile` )) > $swfile
> >> echo exec switchscreen `cat $swfile`
> >>
> >> Note that I just echo-ed the command because I don't have switchscreen
> >> installed. The $(( ... )) syntax allows you to evaluate mathematical
> >> expressions. Read "man bash"
> >>
> >> HTH
> >>

> > Works perfectly! Thanks HTH

>
> Cuong, I'm curious, running dual-screen myself, about your setup. I am
> running xinerama and that combines my two screens into one large
> one. The mouse flows effortlessly from one to the other. I find it
> works very well with a tiling WM (wmii here) and just love it. What do
> you find to be the advantages/disadvantages to have two truly separate
> screens?
>
>
> A



Hi Andrew,

A quick question: what does "a tiling WM (wmii here)" mean?

For my setup: I have one flat monitor (main monitor) and another monitor is
TV, and I want to watch movies on TV and work on another monitor, and that I
do not want my mouse bothers the TV when viewing movies, that is why I setup
so that the mouse can not move from one monitor to another (the mouse is
bounded as normal monitor). Another advantage, I "think" but have not tried
(will try it soon), is that if you have two mice and two keyboards, you can
work on one monitor when your child is playing game on another monitor. Two
separately working desktop with one CPU is cool, right?

KC.

-----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFG/ACyaIeIEqwil4YRArKQAKCXSd3w0REamY1CkqiPuQsaNMRM7QC g0PpU
> sbxto7UAXHnwnwiJjw1Tyfk=
> =tuZx
> -----END PGP SIGNATURE-----
>
>


  Réponse avec citation
Vieux 27/09/2007, 21h40   #6
Andrew Sackville-West
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen

On Thu, Sep 27, 2007 at 04:08:39PM -0400, Nguyen, Cuong K. wrote:
> On 9/27/07, Andrew Sackville-West <andrew@farwestbilliards.com> wrote:
> >
> > Cuong, I'm curious, running dual-screen myself, about your setup. I am
> > running xinerama and that combines my two screens into one large
> > one. The mouse flows effortlessly from one to the other. I find it
> > works very well with a tiling WM (wmii here) and just love it. What do
> > you find to be the advantages/disadvantages to have two truly separate
> > screens?
> >
> >
> > A

>
>
> Hi Andrew,
>
> A quick question: what does "a tiling WM (wmii here)" mean?


a tiling WM is a WM that "tiles" the windows. That is, the windows
don't overlap, but rather occupy as much space as possible and are
laid out on the screen like tiles. wmii is one of the many tiling
WM's. It works by assigning the maximum amount of space to a window
and automatically sizing the window to that space. So with one window
open, it gets the full screen automatically. With two, they share the
screen more or less equally (that's configurable), splitting the
screen horizontally. You can add more windows as desired and the
others will all resize and adjust automatically to make the most of
available screen. You can shift windows into separate columns so that
one window gets full screen height on, say, the left 2/3's of the
screen while the others share the remaining 1/3 of the screen.

>
> For my setup: I have one flat monitor (main monitor) and another monitor is
> TV, and I want to watch movies on TV and work on another monitor, and that I
> do not want my mouse bothers the TV when viewing movies, that is why I setup
> so that the mouse can not move from one monitor to another (the mouse is
> bounded as normal monitor).


okay, that makes sense.

> Another advantage, I "think" but have not tried
> (will try it soon), is that if you have two mice and two keyboards, you can
> work on one monitor when your child is playing game on another monitor. Two
> separately working desktop with one CPU is cool, right?


Kent West does this and calls it dual-seat. search the archives for
his insights on doing this.

A

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFG/BOFaIeIEqwil4YRAvWeAKCgKVGggcYY0ixt38SGzAilD2JvOwC fXXGC
M3U9nuUzm6y0cTeTs/8Z6jI=
=K7Ux
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 27/09/2007, 23h10   #7
Nguyen, Cuong K.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen

On 9/27/07, Andrew Sackville-West <andrew@farwestbilliards.com> wrote:
>
>
> a tiling WM is a WM that "tiles" the windows. That is, the windows
> don't overlap, but rather occupy as much space as possible and are
> laid out on the screen like tiles. wmii is one of the many tiling
> WM's. It works by assigning the maximum amount of space to a window
> and automatically sizing the window to that space. So with one window
> open, it gets the full screen automatically. With two, they share the
> screen more or less equally (that's configurable), splitting the
> screen horizontally. You can add more windows as desired and the
> others will all resize and adjust automatically to make the most of
> available screen. You can shift windows into separate columns so that
> one window gets full screen height on, say, the left 2/3's of the
> screen while the others share the remaining 1/3 of the screen.



Oh, that is a nice feature that I do not know of.

>
> > For my setup: I have one flat monitor (main monitor) and another monitor

> is
> > TV, and I want to watch movies on TV and work on another monitor, and

> that I
> > do not want my mouse bothers the TV when viewing movies, that is why I

> setup
> > so that the mouse can not move from one monitor to another (the mouse is
> > bounded as normal monitor).

>
> okay, that makes sense.
>
> > Another advantage, I "think" but have not tried
> > (will try it soon), is that if you have two mice and two keyboards, you

> can
> > work on one monitor when your child is playing game on another monitor.

> Two
> > separately working desktop with one CPU is cool, right?

>
> Kent West does this and calls it dual-seat. search the archives for
> his insights on doing this.



Yes, dual-seat is what I need, and I find it very convenient and powerful.

> > I am running xinerama and that combines my two screens into one large
> > > one. The mouse flows effortlessly from one to the other. I find it
> > > works very well with a tiling WM (wmii here) and just love it. What do
> > > you find to be the advantages/disadvantages to have two truly separate
> > > screens?



Now you have a sense of why I need dual-seat. What about your setup of
xinerama? What do you find it to be advantages to dual-screen? Actually I
fried xinerama before, but the mouse problem bothered me a lot so that I
switched to dual-screen.

KC.

  Réponse avec citation
Vieux 27/09/2007, 23h40   #8
Andrew Sackville-West
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen

On Thu, Sep 27, 2007 at 06:03:18PM -0400, Nguyen, Cuong K. wrote:
>
>
> Now you have a sense of why I need dual-seat. What about your setup of
> xinerama? What do you find it to be advantages to dual-screen? Actually I
> fried xinerama before, but the mouse problem bothered me a lot so that I
> switched to dual-screen.


I haven't tried two distinct screens, so I can't directly compare
them. I find the moving of the mouse from one screen to the other to
be intuitive and natural for me, but in reality, I rarely use the
mouse anymore. I probably don't need to use xinerama except that it
easily flows with my usage of wmii. For example, in wmii to move a
window into a column on the right of your "screen" you use
Alt-shift-l. I have my wmii set up to split the column at 50%. Since
my screens are the same size, that puts the split right at the edge of
the monitors. I always have more than one window open so I get two
screens each with a full screen window in it. It just naturally works
well for me.

A

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFG/DDCaIeIEqwil4YRAkSfAJ4+AabHkNogyFoKgaqZ1Ak/E8Xp4QCfV4xD
4nkIDceL8Eqa3ZJmts8TQxU=
=a75W
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 29/09/2007, 03h50   #9
Nguyen, Cuong K.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash, xbindkeys and dual screen

On 09/27/2007 06:37 PM, Andrew Sackville-West wrote:
> I haven't tried two distinct screens, so I can't directly compare
> them. I find the moving of the mouse from one screen to the other to
> be intuitive and natural for me, but in reality, I rarely use the
> mouse anymore. I probably don't need to use xinerama except that it
> easily flows with my usage of wmii. For example, in wmii to move a
> window into a column on the right of your "screen" you use
> Alt-shift-l. I have my wmii set up to split the column at 50%. Since
> my screens are the same size, that puts the split right at the edge of
> the monitors. I always have more than one window open so I get two
> screens each with a full screen window in it. It just naturally works
> well for me.
>
>

Yeah Andrew, wmii in your setup of xinerama will be much more
convenient, especially you have two monitors with the same size and they
are placed next to each other. Thanks for pointing that out.

KC.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h43.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,20240 seconds with 17 queries