var plasma = getApiVersion(1);

const kwin = ConfigFile("kwinrc");
kwin.group = "Effect-wobblywindows";
kwin.writeEntry("Drag", 85);
kwin.writeEntry("Stiffness", 10);
kwin.writeEntry("WobblynessLevel", 1);
kwin.group = "Plugins";
kwin.writeEntry("blurEnabled", true);
kwin.writeEntry("better_blur_dxEnabled", false);
kwin.writeEntry("coverswitchEnabled", true);
kwin.writeEntry("flipswitchEnabled", true);
kwin.writeEntry("magiclampEnabled", true);
kwin.writeEntry("glideEnabled", true);
kwin.writeEntry("squashEnabled", false);
kwin.writeEntry("scaleEnabled", false);
kwin.writeEntry("wobblywindowsEnabled", true);
kwin.writeEntry("kwin4_effect_shapecornersEnabled", false);
kwin.group = "Windows";
kwin.writeEntry("BorderlessMaximizedWindows", false);
kwin.group = "org.kde.kdecoration2";
kwin.writeEntry("ButtonsOnLeft", "");
kwin.writeEntry("ButtonsOnRight", "AIX");
kwin.group = "WM";
kwin.writeEntry("activeFont", "Inter,10,-1,5,75,0,0,0,Bold");

const kdeglobals = ConfigFile("kdeglobals");
kdeglobals.group = "General";
kdeglobals.writeEntry(
  "fixed",
  "JetBrainsMono Nerd Font,10,-1,5,700,0,0,0,0,0,0,0,0,0,0,1,Bold,0,0",
);
kdeglobals.writeEntry(
  "font",
  "Inter,10,-1,5,700,0,0,0,0,0,0,0,0,0,0,1,Bold,0,0",
);
kdeglobals.writeEntry("smallestReadableFont", "Inter,8,-1,5,75,0,0,0,0,0,Bold");
kdeglobals.writeEntry("toolBarFont", "Inter,10,-1,5,75,0,0,0,0,0,Bold");
kdeglobals.writeEntry(
  "menuFont",
  "Inter,10,-1,5,700,0,0,0,0,0,0,0,0,0,0,1,Bold,0,0",
);
kdeglobals.writeEntry("ShowDeleteCommand", true);
kdeglobals.writeEntry("SingleClick", true);
kdeglobals.writeEntry("widgetStyle", "kvantum-dark");

const kcminput = ConfigFile("kcminputrc");
kcminput.group = "Mouse";
kcminput.writeEntry("cursorTheme", "Catppuccin-Mocha-Mauve-Cursors");

const panel = new Panel();
panel.alignment = "left";
panel.floating = false;
panel.height = Math.round(gridUnit * 1.8);
panel.location = "top";

var launcher = panel.addWidget("org.kde.plasma.kickoff");
launcher.currentConfigGroup = ["General"];
launcher.writeConfig("icon", "/usr/share/icons/garuda/distributor-logo-garuda-cat.svg");
launcher.writeConfig("lengthFirstMargin", 7);
launcher.currentConfigGroup = ["Shortcuts"];
launcher.writeConfig("global", "Alt+F1");

var title = panel.addWidget("org.kde.windowtitle");
title.currentConfigGroup = ["General"];
title.writeConfig("filterActivityInfo", false);
title.writeConfig("lengthFirstMargin", 7);
title.writeConfig("lengthMarginsLock", false);
title.writeConfig("filterByScreen", true);
title.currentConfigGroup = ["Appearance"];
title.writeConfig("altTxt", "Mokka Kitty 🐱");
title.writeConfig("firstSpace", 7);
title.writeConfig("fontSize", 13);
title.writeConfig("isBold", true);
title.writeConfig("txt", "%a");
title.writeConfig("visible", false);

var plasmaappmenu = panel.addWidget("org.kde.plasma.appmenu");
var spacer = panel.addWidget("org.kde.plasma.panelspacer");

var colorizer = panel.addWidget("luisbocanegra.panel.colorizer")
colorizer.currentConfigGroup = ["General"]
colorizer.writeConfig("hideWidget", true)
colorizer.writeConfig("lastPreset", "/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Transparent")
colorizer.writeConfig("presetAutoloading", '{"enabled":true,"fullscreenWindow":"/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Mokka Maximized","maximized":"/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Mokka Maximized","touchingWindow":"/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Mokka Maximized","activeWindow":"/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Transparent","visibleWindows":"/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Transparent","floating":"/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Transparent","normal":"/usr/share/plasma/plasmoids/luisbocanegra.panel.colorizer/contents/ui/presets/Transparent"}')

var digitalclock = panel.addWidget("org.kde.plasma.digitalclock");
digitalclock.currentConfigGroup = ["Appearance"];
digitalclock.writeConfig("autoFontAndSize", false);
digitalclock.writeConfig("boldText", true);
digitalclock.writeConfig("customDateFormat", "MMM d,");
digitalclock.writeConfig("dateDisplayFormat", "BesideTime");
digitalclock.writeConfig("dateFormat", "custom");
digitalclock.writeConfig(
  "enabledCalendarPlugins",
  "alternatecalendar,astronomicalevents,holidaysevents",
);
digitalclock.writeConfig("font", "Inter,10,-1,5,75,0,0,Bold");
digitalclock.writeConfig("fontFamily", "Inter");
digitalclock.writeConfig("fontSize", 7);
digitalclock.writeConfig("fontStyleName", "Black");
digitalclock.writeConfig("fontWeight", 900);
digitalclock.writeConfig("showWeekNumbers", true);

var spacer = panel.addWidget("org.kde.plasma.panelspacer");
var systray = panel.addWidget("org.kde.plasma.systemtray");
systray.currentConfigGroup = ["General"];
systray.writeConfig("scaleIconsToFit", true);
systray.writeConfig("iconSize", 0);

var switcher = panel.addWidget("org.kde.plasma.userswitcher");
switcher.currentConfigGroup = ["General"];
switcher.writeConfig("showFace", true);
switcher.writeConfig("showName", false);
switcher.writeConfig("showTechnicalInfo", true);

loadTemplate("org.garuda.desktop.defaultDock");

var allDesktops = desktops();
for (var i in allDesktops) {
  var d = allDesktops[i];

  d.currentConfigGroup = ["ActionPlugins", "RightButton;NoModifier"];
  d.writeConfig("plugin", "org.kde.contextmenu");

  d.currentConfigGroup = [
    "ActionPlugins",
    "RightButton;NoModifier",
    "org.kde.contextmenu",
  ];

  d.writeConfig("show_run_command", true); // KRunner
  d.writeConfig("show_lock_screen", true); // Lock
  d.writeConfig("show_logout", true); // Logout
  d.writeConfig("show_leave_group", true); // Other Actions (Shutdown/Restart)

  d.writeConfig("show_add_widgets", true);
  d.writeConfig("show_configure_panel", true);
  d.writeConfig("show_configure_desktop", true); // Wallpaper Actions

  d.writeConfig("show_terminal", true); // Open Terminal
  d.writeConfig("show_create_new", true);
  d.writeConfig("show_paste", true);
}

var allDesktops = desktops();
for (i = 0; i < allDesktops.length; i++) {
  d = allDesktops[i];
  d.wallpaperPlugin = "a2n.blur";
  d.currentConfigGroup = Array("Wallpaper", "a2n.blur", "General");
}
