~protesilaos/dotfiles

1

[PATCH] delight: Add support for Libadwaita color schemes

Details
Message ID
<87lewd79ke.fsf@gmail.com>
DKIM signature
pass
Download raw message
Hello Prot,

First of all, congratulation for award!  Thank you for your
contributions.

GNOME 42 introduced 'dark UI preference', built on top of Libadwita,
which in addition to GTK themes, is used to change system wide color
themes.  Quoting from its release notes:

     A new global dark UI style preference has arrived in GNOME for
     version 42. This can be used to request that apps use a dark UI
     style instead of light. The new setting can be found in the new
     Appearance panel in the Settings app, and is followed by most GNOME
     apps.

And its developer's release notes:

    Libadwaita is a GTK 4 library implementing the GNOME HIG,
    complementing GTK. It is a direct successor to Libhandy, which tried
    to fill this role for GTK 3. Libadwaita 1.0 was released at the end
    of 2021.
    
    Many of the GNOME applications that are being ported to GTK 4 are
    using libadwaita to provide a consistent style and user experience.


Please check the attached patch which tries to add Libadwaita color
scheme support to Delight.

Thank you,
Utkarsh Singh
-- 
Utkarsh Singh
https://utkarshsingh.xyz/
Details
Message ID
<87ee25e89l.fsf@protesilaos.com>
In-Reply-To
<87lewd79ke.fsf@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On 2022-04-10, 11:40 +0530, Utkarsh Singh <utkarsh190601@gmail.com> wrote:

> Hello Prot,

Good day Utkarsh!

> First of all, congratulation for award!

Thank you!

> Thank you for your contributions.

You are welcome!

> GNOME 42 introduced 'dark UI preference', built on top of Libadwita,
> which in addition to GTK themes, is used to change system wide color
> themes.  Quoting from its release notes:
>
>      A new global dark UI style preference has arrived in GNOME for
>      version 42. This can be used to request that apps use a dark UI
>      style instead of light. The new setting can be found in the new
>      Appearance panel in the Settings app, and is followed by most GNOME
>      apps.
>
> And its developer's release notes:
>
>     Libadwaita is a GTK 4 library implementing the GNOME HIG,
>     complementing GTK. It is a direct successor to Libhandy, which tried
>     to fill this role for GTK 3. Libadwaita 1.0 was released at the end
>     of 2021.
>     
>     Many of the GNOME applications that are being ported to GTK 4 are
>     using libadwaita to provide a consistent style and user experience.
>
> Please check the attached patch which tries to add Libadwaita color
> scheme support to Delight.

I installed your patch.  Works well.  I like this feature.

>From 60643dca75847be3038cadb5c09928262356557d Mon Sep 17 00:00:00 2001
> From: Utkarsh Singh <utkarsh190601@gmail.com>
> Date: Sun, 10 Apr 2022 11:17:40 +0530
> Subject: [PATCH] delight: Add support for Libadwaita color schemes
>
> ---
>  bin/bin/delight | 40 +++++++++++++++++++++++++++++++---------
>  1 file changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/bin/bin/delight b/bin/bin/delight
> index df600a41..68820a11 100755
> --- a/bin/bin/delight
> +++ b/bin/bin/delight
> @@ -21,7 +21,7 @@
>  #
>  # Simple tool to switch between light and dark themes.  Primarily
>  # centred around my BSPWM/HerbstluftWM or Sway setup.  For the standard
> -# DEs, this has been tested with GNOME version 3.36 and Xfce 4.16.
> +# DEs, this has been tested with GNOME 42 and Xfce 4.16.
>  #
>  # Part of my dotfiles: <https://gitlab.com/protesilaos/dotfiles>.
>  
> @@ -239,27 +239,46 @@ _ggtk ()
>      gsettings "$1" org.gnome.desktop.interface gtk-theme "${@:2}"
>  }
>  
> -# Get the theme
> -_gget ()
> +_gcolor_scheme ()
> +{
> +    gsettings "$1" org.gnome.desktop.interface color-scheme "${@:2}"
> +}
> +
> +# Get the GTK theme
> +_ggtk_get ()
>  {
>      _ggtk 'get'
>  }
>  
> -# Set the theme
> -_gset ()
> +# Set the GTK theme
> +_ggtk_set ()
>  {
>      _ggtk 'set' "$1"
>  }
>  
> +# Get the Color Scheme
> +_gcolor_scheme_get ()
> +{
> +    _gcolor_scheme 'get'
> +}
> +
> +# Set the Color Scheme
> +_gcolor_scheme_set ()
> +{
> +    _gcolor_scheme 'set' "$1"
> +}
> +
>  _gnome ()
>  {
> -    if [ "$(_gget)" = "'Adwaita'" ]
> +    if [ "$(_ggtk_get)" = "'Adwaita'" ]
>      then
>          style=dark
> -        _gset 'Adwaita-dark'
> +        _ggtk_set 'Adwaita-dark'
> +	_gcolor_scheme_set 'prefer-dark'
>      else
>          style=light
> -        _gset 'Adwaita'
> +        _ggtk_set 'Adwaita'
> +	_gcolor_scheme_set 'prefer-light'
>      fi
>  
>      _emacs "$style"
> @@ -323,12 +342,14 @@ _sway ()
>      then
>          style=dark
>          gtk_theme='Adwaita-dark'
> +	color_scheme='prefer-dark'
>  
>          swaymsg client.focused "#323232" "#323232" "#ffffff" "#ff8059" "#00bcff"
>          swaymsg client.unfocused "#1e1e1e" "#1e1e1e" "#a8a8a8" "#323232" "#323232"
>      else
>          style=light
>          gtk_theme='Adwaita'
> +	color_scheme='prefer-light'
>  
>          swaymsg client.focused "#d7d7d7" "#d7d7d7" "#000000" "#a60000" "#0000c0"
>          swaymsg client.unfocused "#efefef" "#efefef" "#505050" "#d7d7d7" "#d7d7d7"
> @@ -340,7 +361,8 @@ _sway ()
>      _alacritty &
>      _swaybg &
>      # Sway can actually re-use GNOME's settings
> -    _gset "$gtk_theme" &
> +    _ggtk_set "$gtk_theme" &
> +    _gcolor_scheme "$color_scheme" &
>  }
>  
>  #### Sessions

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)