:: Re: [DNG] Does dunst require dbus?
Pàgina inicial
Delete this message
Reply to this message
Autor: Didier Kryn
Data:  
A: dng@lists.dyne.org
Assumpte: Re: [DNG] Does dunst require dbus?
Le 24/01/2016 11:27, Florian Zieboll a écrit :
> On Sat, 23 Jan 2016 21:11:46 +0100
> Adam Borowski<kilobyte@???> wrote:
>
>> >On Sat, Jan 23, 2016 at 08:10:31PM +0100, Florian Zieboll wrote:
>> >
>>> > >I had played a bit with the tiling and highly (GUI) configurable
>>> > >"Terminator" but was bounced back to xterm very quickly due to its
>>> > >footprint and wrote the following secremote.sh script. It has not
>>> > >been tested with more than the few defined colors but I am not
>>> > >aware of any limitations other than that of the X11 palette.
>> >
>> >This approach breaks the moment you ssh from an existing terminal,
>> >especially if you ssh from box 2 to box 3.
>> >
>> >I'd instead recommend setting PS1 in .bashrc on those machines to
>> >something distinct.
> Nice that this also works Xless / on the console:) Although I am not
> too much into working from "behind proxies", I had a closer look at the
> PS1 strings Didier posted in this thread on Friday. I could find the
> backslash escaped special/characters/ documented in the bash(1)
> manpage. A web search for the text formatting (colors and style) of
> course returned a lot of results, including several "PS1 generators",
> some "Extreme Power Prompt" examples [1] and this extensive "Bash
> Prompt HOWTO" [2] at TLDP. But where would I have to look "on board"
> for a documentation of these powerful escape sequences?
>
> By the way, I just noticed that packages.debian.org has the doc-linux
> package listed no longer but in oldoldstable.
>
> Ahoi,
>
> Florian
>
>
>
> [1]http://www.askapache.com/linux/bash-power-prompt.html
> [2]http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/


     Thanks for the links. Actually I think I derived my PS1 settings 
from an example found in some default .bashrc. I found the colors by try 
and fail, or maybe I looked at what ncurses was producing. Of course you 
don't want to use ncurses here since you want to keep a scrolling 
terminal. I eventually wrote a simple C programs which changes the 
color. It understands color names in english and french - easy to change 
to your prefered language.


     Steve can see the use I make of indentation and curly braces 
placement is non-standard, but it makes blocks more visible :-)


#include <stdio.h>
#include <curses.h>
#include <term.h>
#include <string.h>

static int myputc(int c)
{
return fputc(c, stdout);
}

#define defcolor max_colors+1
#define SETCOLOR(C) tputs(tparm(set_foreground, C), 1, myputc)

int main(int argc, char **argv)
{
const char * const couleurs[] =
{"noir", "bleu", "vert", "cyan", "rouge", "magenta", "jaune", "gris"};
const char * const colours[] =
{"black", "blue", "green", "cyan", "red", "magenta", "yellow", "grey"};

int c;
char choix[8];

if(isatty(1)) setupterm(NULL, 1, NULL);
else return 0;

   if(argc>1)
     {
       for(c=0; argv[1][c] && c<8; c++) choix[c] = tolower(argv[1][c]);
       choix[c] = '\0';
       for(c=0; c<8; c++)
         {
           if(!strncmp(couleurs[c], choix, strlen(couleurs[c]))) break;
           if(!strncmp(colours[c], choix, strlen(couleurs[c]))) break;
         }
     }
   else c = defcolor;


SETCOLOR(c);
fflush(stdout);
return 0;
}