delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/08/18/07:49:24

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BB3B385087B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1692359363;
bh=dlxRAlbKyYj4qToUzIb+t9wTGn2esT58fNWtWiB4cTA=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=tI9bsTeFLr9w1ZP73DqitRrJfsByE+d/YaEMbxOp7qv7fQH7E7/Vb80HG34V5HIxU
xOwejtkgx/WjGOgEucHcOVc7kdoyOKJh3mUGXDdft4x+lprYYTCaQQ/b3Wwx0d0ji9
ih9wbEE39QBUGuUY6UZ9OQaUzd6/lUFfSjCZ1nk4=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2671D3858401
Date: Fri, 18 Aug 2023 13:48:47 +0200
To: cygwin AT cygwin DOT com
Subject: Re: Cygwin console: Different default background color when terminal
runs as Admin?
Message-ID: <ZN9an+NaACvTjlc/@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CANH4o6PFnrVbi7TkRn26Q7Sk24fcftZvavwF4vhV9sxFM4MmVQ AT mail DOT gmail DOT com>
<CAB7+T8gVwQtR3XZ6FvAtOkHwZ0AVPzzPOtk2JTA9HBvNQiBfdQ AT mail DOT gmail DOT com>
<CANH4o6Ot_zr5KG0-wpYqJBZq5ux5gEn1ofbBTP7VY=H2oQMzAg AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <CANH4o6Ot_zr5KG0-wpYqJBZq5ux5gEn1ofbBTP7VY=H2oQMzAg@mail.gmail.com>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 37IBnOiH003240

On Aug 18 11:51, Martin Wege via Cygwin wrote:
> On Fri, Aug 18, 2023 at 7:27 AM Jonathon Merz via Cygwin
> <cygwin AT cygwin DOT com> wrote:
> >
> > On Thu, Aug 17, 2023 at 7:13 PM Martin Wege via Cygwin <cygwin AT cygwin DOT com>
> > wrote:
> >
> > > Just an idea: Could the default background color of the Cygwin console
> > > be changed from black to grey (or RED) if the terminal has been
> > > started with Administrator rights?
> > >
> >
> > Assuming that:
> > 1. The Administrators group is called "Administrators"
> > 2. There aren't any non-administrative groups with "Administrators" in the
> > name
> > 3. You're using mintty for your terminal
> >
> > You can run the following in bash or zsh with the desired RGB values:
> >
> > if [[ `id -Gn` == *Administrators* ]]
> > then
> >     echo -ne "\e]11;#FFBBEE\a";
> > fi
> >
> 
> Looking at the output of /usr/bin/id -a was my first guess too. But
> this fails quickly because the names are localized. Seriously MS runs
> the Windows group names through the l10n wringer!! So what works on
> Windows for Germany will surely fail for Windows for Japan. Thus I am
> looking for a more portable solution.
> 
> Maybe the numeric group ids are more 'portable' across the Windows
> versions for different countries?

Admin group is always Windows SID 1-5-32-544 and gid 544 in Cygwin,
unless somebody overloads the gid values via an /etc/group file.

If you want to be really sure, you have to check every numeric gid
returned by `id -G' if it resolves to SID 1-5-32-544.  You can do
this with the getent(1) tool.


Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019