Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kde: replace kdeglobals with Kvantum theme #142

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 40 additions & 152 deletions modules/kde/hm.nix
Original file line number Diff line number Diff line change
@@ -1,161 +1,49 @@
{ pkgs, config, lib, ... }:

with config.stylix.fonts;
with config.lib.stylix.colors;

let
colors = {
BackgroundNormal = "${base00-rgb-r},${base00-rgb-g},${base00-rgb-b}";
BackgroundAlternate = "${base01-rgb-r},${base01-rgb-g},${base01-rgb-b}";

DecorationFocus = "${base01-rgb-r},${base01-rgb-g},${base01-rgb-b}";
DecorationHover = "${base01-rgb-r},${base01-rgb-g},${base01-rgb-b}";

ForegroundNormal = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
ForegroundActive = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
ForegroundInactive = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
ForegroundLink = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
ForegroundNegative = "${base08-rgb-r},${base08-rgb-g},${base08-rgb-b}";
ForegroundNeutral = "${base0D-rgb-r},${base0D-rgb-g},${base0D-rgb-b}";
ForegroundPositive = "${base0B-rgb-r},${base0B-rgb-g},${base0B-rgb-b}";
ForegroundVisited = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
};

colorEffect = {
ColorEffect = 0;
ColorAmount = 0;

ContrastEffect = 1;
ContrastAmount = 0.5;

IntensityEffect = 0;
IntensityAmount = 0;
};

icons = {
Animated = false;

ActiveColor = "${base0A-rgb-r},${base0A-rgb-g},${base0A-rgb-b}";
ActiveColor2 = "${base0A-rgb-r},${base0A-rgb-g},${base0A-rgb-b}";
ActiveEffect = "none";
ActiveSemiTransparent = false;
ActiveValue = 1;

DefaultColor = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
DefaultColor2 = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
DefaultEffect = "none";
DefaultSemiTransparent = false;
DefaultValue = 1;

DisabledColor = "${base03-rgb-r},${base03-rgb-g},${base03-rgb-b}";
DisabledColor2 = "${base03-rgb-r},${base03-rgb-g},${base03-rgb-b}";
DisabledEffect = "none";
DisabledSemiTransparent = true;
DisabledValue = 1;
};

desktopFont = "${sansSerif.name},${toString sizes.desktop},-1,5,50,0,0,0,0,0";
applicationFont = "${sansSerif.name},${toString sizes.applications},-1,5,50,0,0,0,0,0";
monospaceFont = "${monospace.name},${toString sizes.terminal},-1,5,50,0,0,0,0,0";

kdeglobals = {
# The existence of this group makes the following settings unable to
# be changed by the user, as specified at
# https://develop.kde.org/docs/administration/kiosk/introduction/
"$i" = {};

General = {
Name = scheme-name;
ColorScheme = "Breeze";
widgetStyle = "Oxygen";

inherit desktopFont;
fixed = monospaceFont;
font = applicationFont;
menuFont = desktopFont;
taskbarFont = desktopFont;
toolBarFont = desktopFont;
smallestReadableFont = desktopFont;
};

"ColorEffects:Disabled" = colorEffect;
"ColorEffects:Inactive" = colorEffect;

"Colors:Button" = colors;
"Colors:Complementary" = colors;
"Colors:Selection" = colors // {
BackgroundNormal = "${base01-rgb-r},${base01-rgb-g},${base01-rgb-b}";
};
"Colors:Tooltip" = colors;
"Colors:View" = colors;
"Colors:Window" = colors;

WM = {
activeBlend = "${base0A-rgb-r},${base0A-rgb-g},${base0A-rgb-b}";
activeBackground = "${base00-rgb-r},${base00-rgb-g},${base00-rgb-b}";
activeForeground = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";
inactiveBlend = "${base03-rgb-r},${base03-rgb-g},${base03-rgb-b}";
inactiveBackground = "${base00-rgb-r},${base00-rgb-g},${base00-rgb-b}";
inactiveForeground = "${base05-rgb-r},${base05-rgb-g},${base05-rgb-b}";

activeFont = desktopFont;
};

DesktopIcons = icons;
MainToolbarIcons = icons;
PanelIcons = icons;
SmallIcons = icons;
ToolbarIcons = icons;
};

kscreenlockerrc = ''
[Greeter][Wallpaper][org.kde.image][General][$i]
Image=${config.stylix.image}
'';

configDir = pkgs.runCommandLocal "stylix-kde"
{
kdeglobals = (pkgs.formats.ini {}).generate "kdeglobals" kdeglobals;
inherit kscreenlockerrc;
}
''
mkdir $out
cp $kdeglobals $out/kdeglobals
echo "$kscreenlockerrc" >$out/kscreenlockerrc
'';

script = ''
for (desktop of desktops()) {
desktop.wallpaperPlugin = "org.kde.image";
desktop.currentConfigGroup = ["Wallpaper", "org.kde.image", "General"];
desktop.writeConfig("Image", "${config.stylix.image}");
}
'';

in {
{
pkgs,
config,
lib,
...
}: {
options.stylix.targets.kde.enable =
config.lib.stylix.mkEnableTarget "KDE" pkgs.stdenv.hostPlatform.isLinux;

config = lib.mkIf config.stylix.targets.kde.enable {
qt = {
enable = true;
style.name = "breeze";
};
config = lib.mkIf config.stylix.targets.kde.enable (let
kscreenlockerrc = ''
[Greeter][Wallpaper][org.kde.image][General][$i]
Image=${config.stylix.image}
'';

configDir =
pkgs.runCommandLocal "stylix-kde"
{
inherit kscreenlockerrc;
}
''
mkdir $out
echo "$kscreenlockerrc" >$out/kscreenlockerrc
'';

script = ''
for (desktop of desktops()) {
desktop.wallpaperPlugin = "org.kde.image";
desktop.currentConfigGroup = ["Wallpaper", "org.kde.image", "General"];
desktop.writeConfig("Image", "${config.stylix.image}");
}
'';
in {
# We can't just link config files within the home directory because
# they're expected to be writeable.
xdg.systemDirs.config = [ "${configDir}" ];
xdg.systemDirs.config = ["${configDir}"];

# This fails silently unless Plasma is running.
home.activation.kdeWallpaper =
lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.dbus}/bin/dbus-send \
--type=method_call \
--dest=org.kde.plasmashell \
/PlasmaShell \
org.kde.PlasmaShell.evaluateScript \
string:${lib.escapeShellArg script} \
|| true
'';
};
home.activation.kdeWallpaper = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.dbus}/bin/dbus-send \
--type=method_call \
--dest=org.kde.plasmashell \
/PlasmaShell \
org.kde.PlasmaShell.evaluateScript \
string:${lib.escapeShellArg script} \
|| true
'';
});
}
70 changes: 70 additions & 0 deletions modules/kvantum/hm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
pkgs,
config,
lib,
...
}: {
options.stylix.targets.kvantum = {
bluskript marked this conversation as resolved.
Show resolved Hide resolved
enable = config.lib.stylix.mkEnableTarget "Kvantum" pkgs.stdenv.hostPlatform.isLinux;
enableDefaultIcons = lib.mkOption {
description = "Default QT Icons";
type = lib.types.bool;
default = true;
};
};

config = lib.mkIf config.stylix.targets.kvantum.enable (let
cfg = config.stylix.targets.kvantum;
kvconfig = config.lib.stylix.colors {
template = ./kvconfig.mustache;
extension = ".kvconfig";
};
svg = config.lib.stylix.colors {
template = ./kvantum-svg.mustache;
extension = "svg";
};
kvantumPackage = pkgs.runCommandLocal "base16-kvantum" {} ''
mkdir -p $out/share/Kvantum/Base16Kvantum
cat ${kvconfig} >>$out/share/Kvantum/Base16Kvantum/Base16Kvantum.kvconfig
cat ${svg} >>$out/share/Kvantum/Base16Kvantum/Base16Kvantum.svg
'';
in {
home.packages = with pkgs;
[
qt5ct
libsForQt5.qtstyleplugin-kvantum
qt6Packages.qtstyleplugin-kvantum
kvantumPackage
]
++ (lib.optionals cfg.enableDefaultIcons [
papirus-icon-theme
]);

qt = {
enable = true;
platformTheme = "qtct";
};

xdg.configFile."Kvantum/kvantum.kvconfig".source = (pkgs.formats.ini {}).generate "kvantum.kvconfig" {
General.theme = "Base16Kvantum";
};

bluskript marked this conversation as resolved.
Show resolved Hide resolved
xdg.configFile."qt5ct/qt5ct.conf".text =
''
[Appearance]
style=kvantum
''
+ (lib.optionalString cfg.enableDefaultIcons ''
icon_theme=ePapirus-Dark
'');

xdg.configFile."qt6ct/qt6ct.conf".text =
''
[Appearance]
style=kvantum
''
+ (lib.optionalString cfg.enableDefaultIcons ''
icon_theme=ePapirus-Dark
'');
});
}
Loading