LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Is there a WM(?) without the need of keyboard OR mouse? (https://www.linuxquestions.org/questions/linux-general-1/is-there-a-wm-without-the-need-of-keyboard-or-mouse-4175729827/)

Lindgren 10-13-2023 05:08 AM

Is there a WM(?) without the need of keyboard OR mouse?
 
Hi

I have a raspberry pi connected to my TV/Display in the livingroom but I find it rather ineffective to need and connect a vnc session in order to handle it in most ways. Tiling window managers have a logical way of moving windows in a pattern which I like - but it is hard to have it to work with this display since it does not have a keyboard or mouse and often requires a vnc connection for window placement or something that needs to show there.

I would want a (WM?) which I can interact with like over a ssh session or similar, is there such a thing?

In the past I have had my current setup to startup a terminal in full-screen with tmux, which I can connect to and change around in within and I can see it live on the screen, but tmux does not work very well when it comes to graphical content.

I have used Awesome somewhat a while back, if maybe there is a way to send keyboard combinations as a command like [alt] + [1] or [ctrl] + [r] through a command??

Some way to handle graphical stuff without mouse and keyboard pretty much if you know what I mean.

pan64 10-13-2023 05:22 AM

you can ssh to that raspberry from any other computer or even from your phone or tablet.

Lindgren 10-13-2023 06:14 AM

Quote:

Originally Posted by pan64 (Post 6458515)
you can ssh to that raspberry from any other computer or even from your phone or tablet.

Well. yes of course I can, that's not the problem, and it's rather given that I do so in order to interact with the system or VM in any way, as I said already I have tried to use tmux in full screen on the pi (given, connected over ssh), but it does not show graphical stuff. I can set like SCREEN variable to make applications start on the screen but most of them will only stack ontop of eachother without any logical placement.

pan64 10-13-2023 06:30 AM

I still don't understand your problem, probably you want to use remote X session, where the X client and X server run on tho different hosts (called xdmcp). That works on RPi too.
There is a way to forward your display to RPi too, that is described (for example) here: https://hpcf.umbc.edu/general-produc...rams-remotely/

Lindgren 10-13-2023 10:57 AM

Quote:

Originally Posted by pan64 (Post 6458523)
I still don't understand your problem, probably you want to use remote X session, where the X client and X server run on tho different hosts (called xdmcp). That works on RPi too.
There is a way to forward your display to RPi too, that is described (for example) here: https://hpcf.umbc.edu/general-produc...rams-remotely/

Hmm well not really. Well, I am not looking for like full interaction as a regular desktop, I (mostly) need to have logical placement of windows that will show, for instance I open a window and it shows fullscreen, and then a second window and it will arrange accordingly, not just lay ontop, therefore some tiling functionality is preferred. This way I can start applications from the commandline (ssh) and they will arrange in a fair manner without needing a mouse or a vnc connection.

Looking into AwesomeWM again, I just found that there is a awesome-client which I can send certain commands through, like changing desktop, change arrangements and quite a lot in fact which might just be what I am looking for however a bit complicated to step into since I only tried Awesome briefly like ten years ago.

However if there are other ways to achieve this I am all ears, perhaps through some separate application ontop (equivalent like tmux) or other (tiling?) VM with client-functionality?

fatmac 10-13-2023 01:00 PM

Sounds like you are wanting a tiling WM, Awesome is just one of such, there are others.

https://www.tecmint.com/best-tiling-...ers-for-linux/

https://www.slant.co/topics/1902/~be...gers-for-linux

Lindgren 10-13-2023 01:41 PM

Quote:

Originally Posted by fatmac (Post 6458569)
Sounds like you are wanting a tiling WM, Awesome is just one of such, there are others.

https://www.tecmint.com/best-tiling-...ers-for-linux/

https://www.slant.co/topics/1902/~be...gers-for-linux

Yeah I know there are some, only I personally have no user experience of them so hence my question. The problem still being that I don't actually use the tv/screen as a desktop but rather as a showscreen or whatever you would call it, for pictures or whatever fitting the purpose. At the moment I only use the screen for a clockwidget and MPD covers through conky and a terminal opening 'screen' so I can interact with it simply by attaching the same 'screen' elsewere, but it has rather huge limitations and I feel that perhaps there are better alternatives out there. When I found Awesome there was no real mention of this 'awesome-client' functionality, so looking at some other WM might not really expose such functions either right away.

wpeckham 10-13-2023 02:02 PM

Have you considered running something like WEBMIN and controlling it using a web interface instead of bothering with a GUI desktop?

I mean, short of that something like VNC in server mode perhaps - so the GUI runs ONLY in your remote session.

GazL 10-14-2023 05:36 AM

'bspwm' is a tiling window manager that is primarily cli controlled. It might suit your needs if you're prepared to put the work into setting it up.

Lindgren 10-16-2023 02:04 PM

Quote:

Originally Posted by wpeckham (Post 6458581)
Have you considered running something like WEBMIN and controlling it using a web interface instead of bothering with a GUI desktop?

I mean, short of that something like VNC in server mode perhaps - so the GUI runs ONLY in your remote session.

Now, I don't know that much of WEBMIN but isn't that for background processes like handling services which I can anyway handle over ssh?


Quote:

Originally Posted by GazL (Post 6458712)
'bspwm' is a tiling window manager that is primarily cli controlled. It might suit your needs if you're prepared to put the work into setting it up.

Wow! That was far easier than AwesomeWM and configuring that lua which I really don't feel like :-)

dugan 10-16-2023 06:52 PM

Try this, maybe? Apparently it supports remote control via a Unix socket. My search was for window managers that support just that.

https://github.com/jcs/sdorfehs

This should work for what I think you're asking for, which is to open an ssh connection to the computer, launch programs from that ssh session, and have them appear on the computer's attached screen.

Of course, you can always jury-rig it. Just install a tiling window manager on the computer, and have something running in the background that polls a unix socket in a "while read" loop. Then you can ssh in and echo commands into that unix socket.

openbsd98324 11-03-2023 11:12 PM

I ssh to the machine and run :

export DISPLAY=:0 ; ncdeskctrl

It runs a ncurses code that send my keys (keyboard) to the xdotool.
That means you control the machine over ncurses+ssh.
Code is on my git, around.

Lindgren 11-04-2023 08:52 AM

Quote:

Originally Posted by dugan (Post 6459206)
Try this, maybe? Apparently it supports remote control via a Unix socket. My search was for window managers that support just that.

https://github.com/jcs/sdorfehs

This should work for what I think you're asking for, which is to open an ssh connection to the computer, launch programs from that ssh session, and have them appear on the computer's attached screen.

Of course, you can always jury-rig it. Just install a tiling window manager on the computer, and have something running in the background that polls a unix socket in a "while read" loop. Then you can ssh in and echo commands into that unix socket.

Sounds interesting for sure, a little curious about that unixsocket/loop, do you have an example of that?

Quote:

Originally Posted by openbsd98324 (Post 6462700)
I ssh to the machine and run :

export DISPLAY=:0 ; ncdeskctrl

It runs a ncurses code that send my keys (keyboard) to the xdotool.
That means you control the machine over ncurses+ssh.
Code is on my git, around.

Nice! Have been looking for something described like that, will try along with bspwm.

openbsd98324 11-05-2023 05:54 AM

Quote:

Originally Posted by Lindgren (Post 6462767)
Sounds interesting for sure, a little curious about that unixsocket/loop, do you have an example of that?



Nice! Have been looking for something described like that, will try along with bspwm.

Code:




char *strninput( char *myinitstring )
{

        int strninput_gameover = 0;
        char strmsg[PATH_MAX];
        char charo[PATH_MAX];
        strncpy( strmsg, myinitstring , PATH_MAX );

        int ch ;  int foo ;
        int fooj;
        while ( strninput_gameover == 0 )
        {
                getmaxyx( stdscr, rows, cols);
                attroff( A_REVERSE );
                for ( fooj = 0 ; fooj <= cols-1;  fooj++)
                {
                        mvaddch( rows-1, fooj , ' ' );
                }
                mvprintw( rows-1, 0, ":> %s" , strrlf( strmsg ) );
                attron( A_REVERSE );
                printw( " " );
                attroff( A_REVERSE );
                attroff( A_REVERSE );
                attroff( A_BOLD );
                refresh() ;

                curs_set( 0 );
                ch = getch();

                if ( ch == 8 )
                        strncpy( strmsg, strcut( strmsg, 1 , strlen( strmsg ) -1 )  ,  PATH_MAX );

                else if ( ch == 27 ) 
                {
                        strncpy( strmsg, ""  ,  PATH_MAX );
                        strninput_gameover = 1;
                }

                else if ( ch == 274 ) 
                {
                        strncpy( strmsg, ""  ,  PATH_MAX );
                        strninput_gameover = 1;
                }

                else if ( ch == 263 ) 
                        strncpy( strmsg, strcut( strmsg, 1 , strlen( strmsg ) -1 )  ,  PATH_MAX );

                else if ( ch == 4 )
                        strncpy( strmsg, ""  ,  PATH_MAX );

                else if ( ch == 4 )
                {
                        strncpy( strmsg, ""  ,  PATH_MAX );
                }
                else if ( ch == 27 )
                {
                        strncpy( strmsg, ""  ,  PATH_MAX );
                }
                else if (
                                (( ch >= 'a' ) && ( ch <= 'z' ) )
                                || (( ch >= 'A' ) && ( ch <= 'Z' ) )
                                || (( ch >= '1' ) && ( ch <= '9' ) )
                                || (( ch == '0' ) )
                                || (( ch == '~' ) )
                                || (( ch == '!' ) )
                                || (( ch == '&' ) )
                                || (( ch == '=' ) )
                                || (( ch == ':' ) )
                                || (( ch == ';' ) )
                                || (( ch == '<' ) )
                                || (( ch == '>' ) )
                                || (( ch == ' ' ) )
                                || (( ch == '|' ) )
                                || (( ch == '#' ) )
                                || (( ch == '?' ) )
                                || (( ch == '+' ) )
                                || (( ch == '/' ) )
                                || (( ch == '\\' ) )
                                || (( ch == '.' ) )
                                || (( ch == '$' ) )
                                || (( ch == '%' ) )
                                || (( ch == '-' ) )
                                || (( ch == ',' ) )
                                || (( ch == '{' ) )
                                || (( ch == '}' ) )
                                || (( ch == '(' ) )
                                || (( ch == ')' ) )
                                || (( ch == ']' ) )
                                || (( ch == '[' ) )
                                || (( ch == '*' ) )
                                || (( ch == '"' ) )
                                || (( ch == '@' ) )
                                || (( ch == '-' ) )
                                || (( ch == '_' ) )
                                || (( ch == '^' ) )
                                || (( ch == '\'' ) )
                                )
                                {
                                        foo = snprintf( charo, PATH_MAX , "%s%c",  strmsg, ch );
                                        strncpy( strmsg,  charo ,  PATH_MAX );
                                }
                else if ( ch == 10 )
                {
                        strninput_gameover = 1;
                }
        }
        char ptr[PATH_MAX];
        strncpy( ptr, strmsg, PATH_MAX );
        size_t siz = sizeof ptr ;
        char *r = malloc( sizeof ptr );
        return r ? memcpy(r, ptr, siz ) : NULL;
}







///////////////////////////////
///////////////////////////////
///////////////////////////////
char *strtimestamp()
{
        long t;
        struct tm *ltime;
        time(&t);
        ltime=localtime(&t);
        char charo[50];  int fooi ;
        fooi = snprintf( charo, 50 , "%04d%02d%02d%02d%02d%02d",
                        1900 + ltime->tm_year, ltime->tm_mon +1 , ltime->tm_mday,
                        ltime->tm_hour, ltime->tm_min, ltime->tm_sec
                      );
        size_t siz = sizeof charo ;
        char *r = malloc( sizeof charo );
        return r ? memcpy(r, charo, siz ) : NULL;
}








////////////////////////////////
////////////////////////////////
////////////////////////////////
void mvcenter( int myposypass, char *mytext )
{
        mvprintw( myposypass, cols/2 - strlen( mytext )/2  , "%s", mytext );
}


void gfxrectangle( int y1, int x1, int y2, int x2 )
{
        int foo, fooy , foox ;
        foo = x1;
        for( fooy = y1 ; fooy <= y2 ; fooy++)
                for( foox = x1 ; foox <= x2 ; foox++)
                        mvaddch( fooy , foox , ' ' );
}

void gfxframe( int y1, int x1, int y2, int x2 )
{
        int foo, fooy , foox ;
        foo = x1;
        for( fooy = y1 ; fooy <= y2 ; fooy++)
                mvaddch( fooy , foo , ACS_VLINE );
        foo = x2;
        for( fooy = y1 ; fooy <= y2 ; fooy++)
                mvaddch( fooy , foo , ACS_VLINE );
        foo = y1;
        for( foox = x1 ; foox <= x2 ; foox++)
                mvaddch( foo , foox , ACS_HLINE );
        foo = y2;
        for( foox = x1 ; foox <= x2 ; foox++)
                mvaddch( foo , foox , ACS_HLINE );
        mvaddch( y1 , x1 , ACS_ULCORNER );
        mvaddch( y1 , x2 , ACS_URCORNER );
        mvaddch( y2 , x1 , ACS_LLCORNER );
        mvaddch( y2 , x2 , ACS_LRCORNER );
}




void ncurses_runcmd( char *thecmd  )
{
        char rncmdi[PATH_MAX];
        def_prog_mode();
        endwin();
        strncpy( rncmdi , "  " , PATH_MAX );
        strncat( rncmdi , thecmd , PATH_MAX - strlen( rncmdi ) -1 );
        strncat( rncmdi , " " , PATH_MAX - strlen( rncmdi ) -1 );
        system( rncmdi );
        reset_prog_mode();
}


void tcxdotool_screenshot( int tcxmode )
{
        char cmdi[PATH_MAX]; 
        char thefilename[PATH_MAX];
        char lastfile[PATH_MAX];

        def_prog_mode();
        endwin();

        printf( " Entering sleep X... before shot!\n" );
        system( " sleep 1 " );

        strncpy( lastfile, "" , PATH_MAX );
        strncat( lastfile , strtimestamp() , PATH_MAX - strlen( lastfile ) -1 );
        strncat( lastfile , "-" , PATH_MAX - strlen( lastfile ) -1 );
        //strncat( lastfile , "screenshot.png" , PATH_MAX - strlen( lastfile ) -1 );
        strncat( lastfile , filename_description , PATH_MAX - strlen( lastfile ) -1 );
        strncat( lastfile , ".png" , PATH_MAX - strlen( lastfile ) -1 );

        if      ( tcxmode == 1 ) strncpy( cmdi , " scrot " , PATH_MAX );
        else if ( tcxmode == 2 ) strncpy( cmdi , " scrot -s " , PATH_MAX );

        strncat( cmdi , " \"" , PATH_MAX - strlen( cmdi ) -1 );
        strncat( cmdi , lastfile , PATH_MAX - strlen( cmdi ) -1 );
        strncat( cmdi , "\" " , PATH_MAX - strlen( cmdi ) -1 );
        strncat( cmdi , " " , PATH_MAX - strlen( cmdi ) -1 );

        printf( " Let it shot!\n" );
        printf( "cmd: %s\n", cmdi );
        system( cmdi );

        reset_prog_mode();
}



void menu_xdotool()
{
        char charo[PATH_MAX];

        .....

        //// area removed
        {
                erase();
                mvprintw( 0, 0, "mode arrow (hjkl, browser mode): %d" , mode_arrow_keys );
                color_set( 13, NULL ); attroff( A_REVERSE );
                gfxrectangle( rows*25/100, cols*25/100 , rows*75/100, cols*75/100 );
                gfxframe( rows*25/100, cols*25/100 , rows*75/100, cols*75/100 );
                color_set( 17, NULL ); attron( A_REVERSE );
                mvcenter( rows*25/100, "| Menu Xdotool |" );
                color_set( 13, NULL ); attroff( A_REVERSE );
                mvprintw( rows*25/100 +2, cols*25/100+2, "h,j,k,l: xdotool keys ..." );
                mvprintw( rows*25/100 +3, cols*25/100+2, "[0]: Screenshot (scrot!)" );
                mvprintw( rows*25/100 +4, cols*25/100+2, "[9]: Screenshot (scrot selection !)" );
                mvprintw( rows*25/100 +5, cols*25/100+2, "[1]: Screenshot (set filename)" );
                mvprintw( rows*25/100 +5, cols*25/100+2, "[M]: Max (current window)" );
                mvprintw( rows*25/100 +6, cols*25/100+2, "    [%s]", filename_description );

                color_set( 5, NULL ); attron( A_REVERSE );
                mvcenter( rows*75/100 -1, "[ Esc: Cancel ]" );
                mvprintw( rows-1, 0, "|%d|", ch );
                ch = getch();

                if ( mode_arrow_keys == 1 )
                {
                        if ( ch == 'k' )        ncurses_runcmd( " xdotool key Up " );
                        else if ( ch == 'j' )  ncurses_runcmd( " xdotool key Down " );
                        else if ( ch == 'h' )  ncurses_runcmd( " xdotool key Left " );
                        else if ( ch == 'l' )  ncurses_runcmd( " xdotool key Right " );
                        else if ( ch == 'n' )  ncurses_runcmd( " xdotool key Next " );

                        else if ( ch == 10 )  ncurses_runcmd( " xdotool key Return " );
                        else if ( ch == 9 )  ncurses_runcmd( " xdotool key Tab " );

                        if ( ch == 'k' )    ch = 0;
                        else if ( ch == 'j' ) ch = 0;
                        else if ( ch == 'h' )  ch = 0;
                        else if ( ch == 'l' )  ch = 0;
                        else if ( ch == 'n' )  ch = 0;

                        else if ( ch == 10 )  ch = 0;
                        else if ( ch == 9 )  ch = 0;
                }


                if ( ch == 'j' ) 
                        ncurses_runcmd( " xdotool key j " );

                else if ( ch == 27 ) 
                        ncurses_runcmd( " xdotool key Escape " );

                else if ( ch == 10 )    ncurses_runcmd( " xdotool key Return " );

                else if ( ch == 9 )  ncurses_runcmd( " xdotool key Tab " );

                // F-x keys
                else if ( ch == 265 )  ncurses_runcmd( " xdotool key F1 " );
                else if ( ch == 266 )  ncurses_runcmd( " xdotool key F2 " );
                else if ( ch == 267 )  ncurses_runcmd( " xdotool key F3 " );
                else if ( ch == 268 )  ncurses_runcmd( " xdotool key F4 " );
                else if ( ch == 269 )  ncurses_runcmd( " xdotool key F5 " );
                else if ( ch == 270 )  ncurses_runcmd( " xdotool key F6 " );
                else if ( ch == 271 )  ncurses_runcmd( " xdotool key F7 " );
                else if ( ch == 272 )  ncurses_runcmd( " xdotool key F8 " );
                else if ( ch == 273 )  ncurses_runcmd( " xdotool key F9 " );
                else if ( ch == 274 )  ncurses_runcmd( " xdotool key F10 " );
                else if ( ch == 275 )  ncurses_runcmd( " xdotool key F11 " );
                else if ( ch == 276 )  ncurses_runcmd( " xdotool key F12 " );

                else if ( ch == '#' )
                {
                        if ( mode_arrow_keys == 0 )
                                mode_arrow_keys = 1;
                        else
                                mode_arrow_keys = 0;
                }

                else if ( ch == 'M' )
                        ncurses_runcmd( "  wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz  ");

                else if ( ch == KEY_UP ) ncurses_runcmd( " xdotool key Up " );
                else if ( ch == KEY_DOWN ) ncurses_runcmd( " xdotool key Down " );
                else if ( ch == KEY_LEFT ) ncurses_runcmd( " xdotool key Left " );
                else if ( ch == KEY_RIGHT ) ncurses_runcmd( " xdotool key Right " );

                else if ( ch == 'u' ) ncurses_runcmd( " xdotool key Prior " );
                else if ( ch == 'd' ) ncurses_runcmd( " xdotool key Next " );

                else if ( ch == 'G' ) ncurses_runcmd( " xdotool key G " );
                else if ( ch == 'g' ) ncurses_runcmd( " xdotool key g " );

                else if ( ch == 'm' ) ncurses_runcmd( " xdotool key m " );

                else if ( ch == 'j' ) ncurses_runcmd( " xdotool key j " );
                else if ( ch == 'k' ) ncurses_runcmd( " xdotool key k " );
                else if ( ch == 'h' ) ncurses_runcmd( " xdotool key h " );
                else if ( ch == 'l' ) ncurses_runcmd( " xdotool key l " );

                else if ( ch == 'B' ) ncurses_runcmd( " xdotool key B " );
                else if ( ch == 'b' ) ncurses_runcmd( " xdotool key b " );
                else if ( ch == 'z' ) ncurses_runcmd( " xdotool key z " );

                else if ( ch == '+' ) ncurses_runcmd( " xdotool key plus " );
                else if ( ch == '-' ) ncurses_runcmd( " xdotool key minus " );

                else if ( ch == 'Z' ) ncurses_runcmd( " xdotool key Z " );
                else if ( ch == 'z' ) ncurses_runcmd( " xdotool key z " );

                else if ( ch == 'f' ) ncurses_runcmd( " xdotool key f " );
                else if ( ch == 'F' ) ncurses_runcmd( " xdotool key F " );

                else if ( ch == 'q' ) ncurses_runcmd( " xdotool key q " );
                else if ( ch == 'Q' ) ncurses_runcmd( " xdotool key Q " );


                else if ( ch == 32 ) ncurses_runcmd( " xdotool key space " );

                else if ( ch == '0' ) tcxdotool_screenshot( 1 );

                else if ( ch == '1' ) strncpy( filename_description, strninput( "" ) , PATH_MAX );

                else if ( ch == '<' )
                        ncurses_runcmd( " xdotool key less " );
                else if ( ch == '>' )
                        ncurses_runcmd( " xdotool key greater " );

                else if ( ch == '#' )
                        ncurses_runcmd( " xdotool key numbersign " );

                else if ( ch == KEY_RIGHT ) ncurses_runcmd( " xdotool key Right " );
                else if ( ch == KEY_LEFT ) ncurses_runcmd( "  xdotool key Left " );


                else  if ( ch != 0 )
                {

                        snprintf( charo , sizeof( charo ), "  xdotool key %c " , ch );
                        ///printf( "Command to force umount: %s\n", charo );
                        system( charo );
                }

                /*
                  else
                  switch( ch )
                  {
                  case '+':
                  ncurses_runcmd( " xdotool key KP_Add " );
                  break;
                  case '-':
                  ncurses_runcmd( " xdotool key KP_Subtract " );
                  break;
                  case 4: //ctrl+d
                  ncurses_runcmd( " xdotool key Page_Down " );
                  break;
                  case 21: //ctrl+u
                  ncurses_runcmd( " xdotool key Page_Up " );
                  break;
                  case 32:
                  ncurses_runcmd( " xdotool key space " );
                  break;
                  case 127:
                  ncurses_runcmd( " xdotool key BackSpace " );
                  break;
                  }
                */


        }
}



int main()
{

        strncpy(filename_description, "screenshot", PATH_MAX );

        initscr();       
        curs_set( 0 );
        noecho();           
        keypad( stdscr, TRUE );  // for Function keys

        start_color();
        init_pair(0,  COLOR_WHITE,    COLOR_BLACK);
        init_pair(1,  COLOR_RED,    COLOR_BLACK);
        init_pair(2,  COLOR_GREEN,  COLOR_BLACK);
        init_pair(3,  COLOR_YELLOW,  COLOR_BLACK);
        init_pair(4,  COLOR_BLUE,    COLOR_BLACK);
        init_pair(5,  COLOR_MAGENTA, COLOR_BLACK);
        init_pair(6,  COLOR_CYAN,    COLOR_BLACK);
        init_pair(7,  COLOR_BLUE,    COLOR_WHITE);
        init_pair(8,  COLOR_WHITE,  COLOR_RED);
        init_pair(9,  COLOR_BLACK,  COLOR_GREEN);
        init_pair(10, COLOR_BLUE,  COLOR_YELLOW  );
        init_pair(11, COLOR_WHITE,  COLOR_BLUE);
        init_pair(12, COLOR_YELLOW,  COLOR_BLUE);
        init_pair(13, COLOR_BLACK,  COLOR_CYAN);
        init_pair(14, COLOR_BLUE,  COLOR_GREEN);
        init_pair(15, COLOR_BLUE, COLOR_CYAN );
        init_pair(16, COLOR_CYAN, COLOR_WHITE );
        init_pair(17, COLOR_CYAN, COLOR_YELLOW );
        init_pair(18, COLOR_CYAN, COLOR_BLUE);
        init_pair( 19, COLOR_MAGENTA , COLOR_BLUE);
        init_pair( 20 , COLOR_RED , COLOR_BLUE);
        init_pair( 21 , COLOR_BLUE , COLOR_YELLOW);
        init_pair( 22, COLOR_YELLOW,  COLOR_CYAN);
        init_pair( 23, COLOR_WHITE, COLOR_BLUE);
        init_pair( 24, COLOR_GREEN, COLOR_BLUE);
        getmaxyx( stdscr, rows , cols);

        menu_xdotool();

        endwin();
        return 0;
}


openbsd98324 12-02-2023 09:23 AM

Hi ... herewith a newer code very simple using termios.

Quote:



// A Little workaround ... X11 without mouse ...
// cc code.c -o code ; ./code


#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>


int main()
{
printf( " => Termios for Beginners: For Linux Questions ... \n" );

struct termios ot;
if(tcgetattr(STDIN_FILENO, &ot) == -1) perror(")-");
struct termios t = ot;
t.c_lflag &= ~(ECHO | ICANON);
t.c_cc[VMIN] = 1;
t.c_cc[VTIME] = 0;
if( tcsetattr( STDIN_FILENO, TCSANOW, &t) == -1) perror(")-");
int a; int b;
while( a = getchar(), a != 'q')
{
fprintf( stderr, "you pressed '%c'\n", a);

if ( a == 'x' )
system( " xdotool key x " );

else if ( a == 'y' )
system( " xdotool key y " );

else if ( a == 'z' )
system( " xdotool key z " );

else if ( a == '[' )
{
fprintf( stderr, "you pressed '%c', the key [\n", a);
b = getchar();
fprintf( stderr, "you pressed the escape with '%c'.\n", b );

if ( b == 'A' )
{
fprintf( stderr, "you pressed '%c', the key A so Up then.\n", b );
system( " xdotool key Up " );
}

else if ( b == 'B' )
{
fprintf( stderr, "you pressed '%c', the key B so Down then.\n", b );
system( " xdotool key Down " );
}

else if ( b == 'D' )
{
fprintf( stderr, "you pressed '%c', the key D so Left then.\n", b );
system( " xdotool key Left " );
}

else if ( b == 'C' )
{
fprintf( stderr, "you pressed '%c', the key C so Right then.\n", b );
system( " xdotool key Right " );
}
}

}
if(tcsetattr(STDIN_FILENO, TCSANOW, &ot) == -1) perror(")-");

return 0;
}




All times are GMT -5. The time now is 09:22 AM.