X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FAF03865C15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1692363386; bh=lKbJ5qki0dDRetXT23ExOeZ2YTf2qP/DgKx8dokkpbM=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=obAO51SVx5pOgzeMOep0lmY9EEEivdiX9su1V6HoqlE5AJtdRSac5eaOA8yNkTzep FxJV5GSddKwv7wOVUuv+vNFbtyvtmuSBi8+biuaNk4Qu/0f8Tas5w8l/zmsEmRnIPq 66bun6hzspC6Wxu2jNjwBztjyj2BHqmbItkrp6cs= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AA133858401 Subject: Re: Cygwin console: Different default background color when terminal runs as Admin? To: cygwin AT cygwin DOT com References: Message-ID: <0e260ffb-f29f-7a19-6bc9-cfd616484eec@t-online.de> Date: Fri, 18 Aug 2023 14:55:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 SeaMonkey/2.53.16 MIME-Version: 1.0 In-Reply-To: X-TOI-EXPURGATEID: 150726::1692363347-F67E2EBC-8E888DF5/0/0 CLEAN NORMAL X-TOI-MSGID: 2190109d-fba9-4e92-860a-f38b0b80ae68 X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christian Franke via Cygwin Reply-To: Christian Franke Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 37ICuRXs018871 Corinna Vinschen via Cygwin wrote: > 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. Fortunately getent allows multiple keys, so this works: case "$(getent group $(id -G))" in   *:S-1-5-32-544:*) echo admin ;; esac Unfortunately this may be is slow in domains due to unneeded AD requests. Unlike mkgroup, getent output cannot be restricted to local groups (and the '-s SERVICE' option is apparently a no-op). -- Regards, Christian -- 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