You are not logged in.

#1 2008-08-16 10:56:13

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

[SOLVED] screen mirrored in terminal hotkey

hi! im using urxvt and xterm, and i realized that everytime i restart X i open 3-4 terminals and then mirror my screen session wit lot of screens in it...

So i was wondering if there's some way to make a hotkey for use in say dwm to open a urxvt with screen mirrored to it

i have this in ~/.bashrc

### Screen Function Mirror/List :: sx ###
function sx {
if [[ $1 ]]; then
    screen -x $1
else
    screen -ls
fi
}

It shows me a thing like this when attached:

[aleyscha@aleyscha 1 ~]$ sx 
There is a screen on:
    4565.pts-3.aleyscha    (Attached)
1 Socket in /tmp/screens/S-aleyscha.

and it shows me a thing like this when attached:

[aleyscha@aleyscha 1 ~]$ sx 
There is a screen on:
    4565.pts-3.aleyscha    (Dettached)
1 Socket in /tmp/screens/S-aleyscha.

Thankyou 4 read

Last edited by leo2501 (2008-08-17 12:50:45)


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

#2 2008-08-16 11:08:20

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] screen mirrored in terminal hotkey

Not sure what you mean by 'mirror' in this context, but if you want to run screen, or any other command, when you launch urxvt, use the -e flag.

Offline

#3 2008-08-16 11:33:39

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

Re: [SOLVED] screen mirrored in terminal hotkey

tomk wrote:

Not sure what you mean by 'mirror' in this context, but if you want to run screen, or any other command, when you launch urxvt, use the -e flag.

sorry, i mean, to start screen with this option:
-x   Attach  to a not detached screen session. (Multi display mode).

so when i open a terminal i need the screen session number, and i don't know how to get it in a script i get (with screen -ls) the attached and dettached sessions, and i have always only one, and that one i want to have attached with the -x session that allows you to have it attached to several terminals


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

#4 2008-08-16 12:23:53

flx
Member
Registered: 2006-01-06
Posts: 9

Re: [SOLVED] screen mirrored in terminal hotkey

If I understand you correctly, something like this in your .bashrc could work:

case $TERM in
        xterm*|rxvt*)
                if screen -ls | grep -q Main; then
                        screen -xr Main
                else
                        screen -S Main
                fi
        ;;
esac

Last edited by flx (2008-08-16 12:24:48)

Offline

#5 2008-08-16 14:36:10

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

Re: [SOLVED] screen mirrored in terminal hotkey

flx wrote:

If I understand you correctly, something like this in your .bashrc could work:

case $TERM in
        xterm*|rxvt*)
                if screen -ls | grep -q Main; then
                        screen -xr Main
                else
                        screen -S Main
                fi
        ;;
esac

Wow! that's perfect! the only thing is that i want to make it behave like a keybinding, so i can still have a non-screen terminal, so i think i need to make it a function, something like:

function scr {
case $TERM in
        xterm*|rxvt*)
                if screen -ls | grep -q Main; then
                        screen -xr Main
                else
                        screen -S Main
                fi
        ;;
esac
}

so i can add a keybinding in dwm to start a "urxvt -e scr" command isn't it?


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

#6 2008-08-17 12:50:15

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

Re: [SOLVED] screen mirrored in terminal hotkey

well it's done smile THANKYOU flx! i done it with this:

get_screen script:

#!/bin/bash
if screen -ls | grep -q Main; then
    screen -xr Main
    else
    screen -S Main
fi

and this in dwm's config.h file:

...
/* commands */
static const char *termscreen[]   = { "urxvt", "-e", "get_screen", NULL };;
...
static Key keys[] = {
{ MODKEY|ControlMask,           XK_Return, spawn,          {.v = termscreen } },
...

I love dwm and screen big_smile


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

Board footer

Powered by FluxBB