/*******Panel Top*********/
paneltop = new Panel
paneltop.hiding = "none"
paneltop.location = "top"
paneltop.height = 24
paneltop.offset = 0
/****conociendo la resolucion de pantalla*/
const width = screenGeometry(paneltop.screen).width
/**/
function separators(a){
if (width <= 1280){
    c = 1
} else { if (width <= 1440){
    c = 2
} else
{
    c = 3
}
}
    for (b = 0; b < c; b++)
        a.addWidget("org.kde.plasma.marginsseparator")
}
function separatorsTray(){
if (width <= 1280){
    c = 2
} else { if (width <= 1440){
    c = 4
} else
{
    c = 6
}
}
return c
}

let localerc;
try {
    localerc = ConfigFile('plasma-localerc');
    localerc.group = "Formats";
} catch (e) {
    // Si no se puede abrir el archivo, establecer leng a "en"
    localerc = null;
}

let leng = "en"; // Valor por defecto
if (localerc) {
    let langEntry = localerc.readEntry("LANG");
    if (langEntry !== "") {
        leng = langEntry;
    }
}

let textlengu = leng.substring(0, 2);

function desktoptext(languageCode) {
    const translations = {
        "es": "Escritorio",         // Spanish
        "en": "Desktop",            // English
        "hi": "डेस्कटॉप",           // Hindi
        "fr": "Bureau",             // French
        "de": "Desktop",            // German
        "it": "Desktop",            // Italian
        "pt": "Área de trabalho",   // Portuguese
        "ru": "Рабочий стол",       // Russian
        "zh": "桌面",               // Chinese (Mandarin)
        "ja": "デスクトップ",        // Japanese
        "ko": "데스크톱",            // Korean
        "nl": "Bureaublad",         // Dutch
        "ny": "Detskyopi",          // Chichewa
        "mk": "Десктоп"             // Macedonian
    };

    // Return the translation for the language code or default to English if not found
    return translations[languageCode] || translations["en"];
}

/*kapple*/
separators(paneltop)
//paneltop.addWidget("org.kde.plasma.appmenu")
paneltop.addWidget("org.kde.plasma.panelspacer")
paneltop_clock = paneltop.addWidget("org.kde.plasma.digitalclock")
paneltop_clock.currentConfigGroup = ["Appearance"]
paneltop_clock.writeConfig("use24hFormat", '0')
paneltop_clock.writeConfig("customDateFormat", "MMM d")
paneltop_clock.writeConfig("dateDisplayFormat", "BesideTime")
paneltop_clock.writeConfig("dateFormat", "custom")
paneltop_clock.writeConfig("fontFamily", "Zoho Puvi")
paneltop_clock.writeConfig("fontSize", "16")
paneltop_clock.writeConfig("fontStyleName", "Medium")
paneltop.addWidget("org.kde.plasma.panelspacer")
separators(paneltop)

/*added systemtray*/
var systraprev = paneltop.addWidget("org.kde.plasma.systemtray")
var SystrayContainmentId = systraprev.readConfig("SystrayContainmentId")
const systray = desktopById(SystrayContainmentId)
systray.currentConfigGroup = ["General"]

/* Fix - Modifying extraItems leads to missing volume icon at live boot if we use desktopById() to get the systemtray containment group */
// systray.writeConfig("extraItems", "org.kde.plasma.volume,org.kde.plasma.devicenotifier,org.kde.plasma.battery,org.kde.plasma.printmanager,org.kde.plasma.clipboard,org.kde.kscreen,org.kde.plasma.notifications,org.kde.plasma.networkmanagement,org.kde.plasma.nightcolorcontrol,org.kde.plasma.bluetooth,ibus-ui-gtk3,Discover Notifier_org.kde.DiscoverNotifier")

//There are certain items that may not be part of OS applet but an app may force them to display, in that case those must be known to system tray
systray.writeConfig("knownItems", "org.kde.plasma.volume,org.kde.plasma.devicenotifier,org.kde.plasma.battery,org.kde.plasma.printmanager,org.kde.plasma.clipboard,org.kde.kscreen,org.kde.plasma.notifications,org.kde.plasma.networkmanagement,org.kde.plasma.bluetooth")

//Always visible at panel
systray.writeConfig("shownItems","org.kde.plasma.volume,org.kde.plasma.battery,org.kde.plasma.networkmanagement")

//Always inside drop down
systray.writeConfig("hiddenItems","org.kde.plasma.vault,org.kde.kdeconnect,org.kde.plasma.printmanager,org.kde.plasma.nightcolorcontrol,org.kde.plasma.manage-inputmethod,org.kde.kupapplet,org.kde.plasma.keyboardindicator,org.kde.plasma.keyboardlayout,ibus-ui-gtk3,Discover Notifier_org.kde.DiscoverNotifier,KDE Daemon")

systray.writeConfig("scaleIconsToFit", "true")
//systray.writeConfig("iconSpacing", separatorsTray())

// separators(paneltop)
paneltop.addWidget("org.kde.plasma.marginsseparator")
paneltop.addWidget("org.kde.milou")
paneltop.addWidget("org.kde.plasma.marginsseparator")
            /****************************/
panelbottom = new Panel
 panelbottom.location = "bottom"
  panelbottom.height = 66
   panelbottom.offset = 0
    panelbottom.alignment = "center"
     panelbottom.panelVisibility = "2"
      if (width === 1920){
      panelbottom.maximumLength = 1728
       } else
     {
       if (width === 1440){
      panelbottom.maximumLength = 1296
       } else
     {
       if (width === 1280){
      panelbottom.maximumLength = 1152
       } else
     {
       panelbottom.maximumLength = Number((width)*(.90))
    }
    }
    }
    panelbottom.minimumLength = 120
        panelbottom.hiding = "windowscover"
         panelbottom.addWidget("org.kde.plasma.marginsseparator")
          panelbottom_start = panelbottom.addWidget("TiledScreen")
           panelbottom_start.currentConfigGroup = ["General"]
            panelbottom_start.writeConfig("customButtonImage", "/usr/share/zos/gui/app/start-menu.svg")
             panelbottom_start.writeConfig("useCustomButtonImage", "true")
             panelbottom_start.writeConfig("showFavorites", "false")
             // panelbottom_start.writeConfig("showSystemActions", "false")
             panelbottom_start.writeConfig("showUserInfo", "false")
             panelbottom_start.writeConfig("showBackLabels", "false")
panelbottom_start.currentConfigGroup = ["Shortcuts"]
panelbottom_start.writeConfig("global", "Meta+Z")
icon_task = panelbottom.addWidget("org.kde.plasma.icontasks")
icon_task.currentConfigGroup = ["General"]
icon_task.writeConfig("fill","false")
    panelbottom.addWidget("org.kde.plasma.trash")
    panelbottom_sysleave = panelbottom.addWidget("org.kde.plasma.lock_logout")
    panelbottom_sysleave.currentConfigGroup = ["General"];
    panelbottom_sysleave.writeConfig("show_lockScreen", "false")
     /*separator*/
    panelbottom.addWidget("org.kde.plasma.marginsseparator")
     /*separator /*/
     /******************************/
/*Cambiando configuracion Dolphin*/
const IconsStatic_dolphin = ConfigFile('dolphinrc')
IconsStatic_dolphin.group = 'KFileDialog Settings'
IconsStatic_dolphin.writeEntry('Places Icons Static Size', 16)
const PlacesPanel = ConfigFile('dolphinrc')
PlacesPanel.group = 'PlacesPanel'
PlacesPanel.writeEntry('IconSize', 16)
/*Buttons of aurorae*/
Buttons = ConfigFile("kwinrc")
Buttons.group = "org.kde.kdecoration2"
Buttons.writeEntry("ButtonsOnLeft", "M")
Buttons.writeEntry("ButtonsOnRight", "IAX")
/******************************/
let IDPanel = "Panel"+" "+panelbottom.id
/*cambiando config*/
const config = ConfigFile('plasmashellrc')
config.group = 'PlasmaViews'
const config2 = ConfigFile(config, IDPanel)
config2.writeEntry('floating', 1)
/* accent color config*/
ColorAccetFile = ConfigFile("kdeglobals")
ColorAccetFile.group = "General"
ColorAccetFile.writeEntry("accentColorFromWallpaper", "false")
ColorAccetFile.deleteEntry("AccentColor")
ColorAccetFile.deleteEntry("LastUsedCustomAccentColor")

var desktopsArray = desktopsForActivity(currentActivity());
for( var j = 0; j < desktopsArray.length; j++) {
    desktopsArray[j].wallpaperPlugin = 'org.kde.image';
}
