From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 2671D3858401; Fri, 18 Aug 2023 11:48:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2671D3858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1692359329; bh=t+Svh3VM3No56IRKC7GSCPxOnOk8FrYwvB+V5qSci38=; h=Date:From:To:Subject:Reply-To:References:In-Reply-To:From; b=V0qOGgeDuJu4jy5/+G05GHyr0xJCMHunmsvlARcGCH1YmergBSPrsVfVbBB7ArLGr d7u8cI81TamjMXaHOIc/SU1fwJvMihjhez2b82wK4hYX7n/OOOoplwJeVzKqjvz4ox HtpnXT1z5UNzTIA75O4rBltrsM6fguGvaTZBsxDQ= Received: by calimero.vinschen.de (Postfix, from userid 500) id 24CC3A80721; Fri, 18 Aug 2023 13:48:47 +0200 (CEST) Date: Fri, 18 Aug 2023 13:48:47 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Cygwin console: Different default background color when terminal runs as Admin? Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: On Aug 18 11:51, Martin Wege via Cygwin wrote: > On Fri, Aug 18, 2023 at 7:27 AM Jonathon Merz via Cygwin > wrote: > > > > On Thu, Aug 17, 2023 at 7:13 PM Martin Wege via Cygwin > > 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