예제 #1
0
def kwinThemer(theme):
    kwinThemes = {
        "air-black": ["PluginLib=kwin3_aurorae", True, "[Engine]\nThemeName=Air-black-remix-green"],
        "cupertino-ish": ["PluginLib=kwin3_aurorae", True, "[Engine]\nThemeName=cupertino-ish"],
        "oxygen": ["PluginLib=kwin3_oxygen", False, None],
        "plastik": ["PluginLib=kwin3_aurorae", True, "[Engine]\nEngineType=qml\nThemeName=kwin4_decoration_qml_plastik"],
    }
    
    for themeName, themeSettings in kwinThemes.items():
        if theme == themeName:
            query = "PluginLib"
            with open(kwinRC, mode='r', encoding='utf-8') as search:
                for line in search:
                    line = line.rstrip()
                    if line.startswith(query):
                        search.close()
                        break
            kwinFileRead = open(kwinRC).read()
            kwinFileRead = kwinFileRead.replace(line, themeSettings[0])
            kwinFileWrite = open(kwinRC, mode='w', encoding='utf-8')
            kwinFileWrite.write(kwinFileRead)
            kwinFileWrite.close()
        
            if themeSettings[1]:
                openAuroraerc = open(auroraeRC, mode='w', encoding='utf-8')
                openAuroraerc.write(themeSettings[2])
                openAuroraerc.close()
        
            logger.writeLog('changeTheme', themeName)
            return True
예제 #2
0
def handlePackages(packagesTBI, packagesTBR): #packagesTBI = packages to be installed #packagesTBR = packages to br removed
    currentPackages = getCurrentPackages()
    
    packagesTBIListUnedited = list(set(packagesTBI) - set(currentPackages)) #Packages to be installed
    packagesTBNList = list(set(currentPackages) - set(packagesTBR)) #Packages that don't need to be removed or installed (neutral).
    packagesTBRListUnedited = list(set(currentPackages) - set(packagesTBNList)) #Packages to be removed
    
    packagesTBIList = packagesTBIListUnedited
    for packageName, packagesAdditions in packagesInstallAdditions.items():
        if packageName in packagesTBIListUnedited:
            packagesTBIList = packagesTBIList + list(set(packagesInstallAdditions[packageName]) - set(packagesTBNList))
    
    packagesTBRList = packagesTBRListUnedited
    for packageName, packagesAdditions in packagesRemoveAdditions.items():
        if packageName in packagesTBRListUnedited:
            packagesTBRList = packagesTBRList + list(set(packagesRemoveAdditions[packageName]) & set(packagesTBNList))
    
    packagesTBIStr = ' '.join(packagesTBIList)
    packagesTBRStr = ' '.join(packagesTBRList)
    logger.writeLog("packagesToBeInstalled", packagesTBIStr)
    logger.writeLog("packagesToBeRemoved", packagesTBRStr)
    
    installPackages = subprocess.Popen(["lxterminal", "-e", "bash",  "/usr/share/turbulence/scripts/install-packages.sh", "\"" + ' '.join(packagesTBIList) + "\"", "-r", "\"" + ' '.join(packagesTBRList) + "\""])
    sleep(2)
    system("wmctrl -a LXTerminal")
예제 #3
0
def startKwin():
    subprocess.Popen([
        "dbus-send", "--dest=org.kde.kwin", "/KWin",
        "org.kde.KWin.reloadConfig"
    ],
                     stdout=subprocess.PIPE)
    logger.writeLog('startKwin')
예제 #4
0
def panelPosition(position):
    positionValues = {
        "top": ["panel_position = top center horizontal", "task_text = 1"],
        "bottom": ["panel_position = bottom center horizontal", "task_text = 1"],
        "right": ["panel_position = center right vertical", "task_text = 0"],
        "left": ["panel_position = center left vertical", "task_text = 0"],
    }
    
    for screenPosition, positionSettings in positionValues.items():
        if position == screenPosition:
            query = "panel_position"
            with open(tintTwo, mode='r', encoding='utf-8') as search:
                for panel_position in search:
                    panel_position = panel_position.rstrip()
                    if panel_position.startswith(query):
                        search.close()
                        break
            
            query = "task_text"
            with open(tintTwo, mode='r', encoding='utf-8') as search:
                for task_text in search:
                    task_text = task_text.rstrip()
                    if task_text.startswith(query):
                        search.close()
                        break
                
            tintTwoRead = open(tintTwo).read()
            tintTwoRead = tintTwoRead.replace(panel_position, positionSettings[0])
            tintTwoRead = tintTwoRead.replace(task_text, positionSettings[1])
            tintTwoWrite = open(tintTwo, mode='w', encoding='utf-8')
            tintTwoWrite.write(tintTwoRead)
            tintTwoWrite.close()
        
            logger.writeLog('changedTintPanel', screenPosition)
            return True
예제 #5
0
def changeWallpaperOpenbox(wallpaperChoice, wallpaperOptions):
    for wallpaperName, wallpaperPath in wallpaperOptions.items():
        if wallpaperChoice == wallpaperName:
            setWallpaper = subprocess.Popen(
                ["nitrogen", "--set-scaled", "--save", wallpaperPath],
                stdout=subprocess.PIPE)
            setWallpaper.wait()
            logger.writeLog("changedWallpaper", wallpaperName)
예제 #6
0
def createDir(directory, directoryXDG):
    ###########
    #IMPORTANT#
    ###########
    
    ####################################################
    #Due to the nature of the thus graphical installer
    #Already creating all of the users home directories
    #Already localized, I've disabled this feature 
    #Temporarily due to some complications with xdg
    #It will be re-enabled when the proper code is found 
    #To perform these actions. Otherwise, the below code
    #Will not work as is.
    ####################################################
    #TODO enable this functionality again, and fix code.
    
    #if os.path.exists(xdgDummyConf):
        #try:
           #with open(fullPath) as xdgConfig:
              #homeDirsNames = [line.rstrip('\n') for line in xdgConfig if not line.startswith("#")]
              #homeDirDic = {}
              #for dirName in homeDirsNames:
                  #homeDirDic[dirName.split('=')[0]] = ''.join(dirName.split('=')[1:])
        #except IOError:
           #print "Couldn't parse the " + fullPath + " Configuration file."
           
    #for xdgVar, homeDirValue in homeDirDic.items():
        #if xdgVar == directory:
            #if homeDirValue != "\"$HOME/\"":
                #print "Assume created..."
            #else:
                #print "Assume creation..."           
                
    
    fullPath = homeDir + "/" + directory
    if not os.path.exists(fullPath):
        os.makedirs(fullPath)
        os.system('xdg-user-dirs-update --set ' + directoryXDG.partition('XDG_')[-1].rpartition('_DIR')[0] + ' $HOME/' + directory)
        logger.writeLog('createdDir', fullPath)
    else:
        os.system('xdg-user-dirs-update --set ' + directoryXDG.partition('XDG_')[-1].rpartition('_DIR')[0] + ' $HOME/' + directory)
        logger.writeLog('dirAlreadyExists', fullPath)
        return False
    return True
예제 #7
0
def changeWallpaperKde(wallpaperChoice, wallpaperOptions):
    if not plasmaRCExists():
        print("You don't seem to have a " + fullPath + " file.")
        return False

    for wallpaperName, wallpaperPath in wallpaperOptions.items():
        if wallpaperChoice == wallpaperName:
            query = "wallpaper="
            with open(fullPath, mode='r', encoding='utf-8') as search:
                for line in search:
                    line = line.rstrip()
                    if line.startswith(query):
                        search.close()
                        break
            plasmaRCRead = open(fullPath).read()
            plasmaRCRead = plasmaRCRead.replace(line, wallpaperPath)
            plasmaRCWrite = open(fullPath, mode='w', encoding='utf-8')
            plasmaRCWrite.write(plasmaRCRead)
            plasmaRCWrite.close()
            logger.writeLog('changedWallpaper', wallpaperChoice)
            return True
예제 #8
0
def changeWallpaperKde(wallpaperChoice, wallpaperOptions):
    if not plasmaRCExists():
        print("You don't seem to have a " + fullPath + " file.")
        return False
      
    for wallpaperName, wallpaperPath in wallpaperOptions.items():
        if wallpaperChoice == wallpaperName:
            query = "wallpaper="
            with open(fullPath, mode='r', encoding='utf-8') as search:
                for line in search:
                    line = line.rstrip()
                    if line.startswith(query):
                        search.close()
                        break
            plasmaRCRead = open(fullPath).read()
            plasmaRCRead = plasmaRCRead.replace(line, wallpaperPath)
            plasmaRCWrite = open(fullPath, mode='w', encoding='utf-8')
            plasmaRCWrite.write(plasmaRCRead)
            plasmaRCWrite.close()
            logger.writeLog('changedWallpaper', wallpaperChoice)
            return True
예제 #9
0
def handlePackages(
    packagesTBI, packagesTBR
):  #packagesTBI = packages to be installed #packagesTBR = packages to br removed
    currentPackages = getCurrentPackages()

    packagesTBIListUnedited = list(
        set(packagesTBI) - set(currentPackages))  #Packages to be installed
    packagesTBNList = list(
        set(currentPackages) - set(packagesTBR)
    )  #Packages that don't need to be removed or installed (neutral).
    packagesTBRListUnedited = list(
        set(currentPackages) - set(packagesTBNList))  #Packages to be removed

    packagesTBIList = packagesTBIListUnedited
    for packageName, packagesAdditions in packagesInstallAdditions.items():
        if packageName in packagesTBIListUnedited:
            packagesTBIList = packagesTBIList + list(
                set(packagesInstallAdditions[packageName]) -
                set(packagesTBNList))

    packagesTBRList = packagesTBRListUnedited
    for packageName, packagesAdditions in packagesRemoveAdditions.items():
        if packageName in packagesTBRListUnedited:
            packagesTBRList = packagesTBRList + list(
                set(packagesRemoveAdditions[packageName])
                & set(packagesTBNList))

    packagesTBIStr = ' '.join(packagesTBIList)
    packagesTBRStr = ' '.join(packagesTBRList)
    logger.writeLog("packagesToBeInstalled", packagesTBIStr)
    logger.writeLog("packagesToBeRemoved", packagesTBRStr)

    installPackages = subprocess.Popen([
        "lxterminal", "-e", "bash",
        "/usr/share/turbulence/scripts/install-packages.sh",
        "\"" + ' '.join(packagesTBIList) + "\"", "-r",
        "\"" + ' '.join(packagesTBRList) + "\""
    ])
    sleep(2)
    system("wmctrl -a LXTerminal")
예제 #10
0
def panelPosition(position):
    positionValues = {
        "top": ["panel_position = top center horizontal", "task_text = 1"],
        "bottom":
        ["panel_position = bottom center horizontal", "task_text = 1"],
        "right": ["panel_position = center right vertical", "task_text = 0"],
        "left": ["panel_position = center left vertical", "task_text = 0"],
    }

    for screenPosition, positionSettings in positionValues.items():
        if position == screenPosition:
            query = "panel_position"
            with open(tintTwo, mode='r', encoding='utf-8') as search:
                for panel_position in search:
                    panel_position = panel_position.rstrip()
                    if panel_position.startswith(query):
                        search.close()
                        break

            query = "task_text"
            with open(tintTwo, mode='r', encoding='utf-8') as search:
                for task_text in search:
                    task_text = task_text.rstrip()
                    if task_text.startswith(query):
                        search.close()
                        break

            tintTwoRead = open(tintTwo).read()
            tintTwoRead = tintTwoRead.replace(panel_position,
                                              positionSettings[0])
            tintTwoRead = tintTwoRead.replace(task_text, positionSettings[1])
            tintTwoWrite = open(tintTwo, mode='w', encoding='utf-8')
            tintTwoWrite.write(tintTwoRead)
            tintTwoWrite.close()

            logger.writeLog('changedTintPanel', screenPosition)
            return True
예제 #11
0
def kwinThemer(theme):
    kwinThemes = {
        "air-black": [
            "PluginLib=kwin3_aurorae", True,
            "[Engine]\nThemeName=Air-black-remix-green"
        ],
        "cupertino-ish":
        ["PluginLib=kwin3_aurorae", True, "[Engine]\nThemeName=cupertino-ish"],
        "oxygen": ["PluginLib=kwin3_oxygen", False, None],
        "plastik": [
            "PluginLib=kwin3_aurorae", True,
            "[Engine]\nEngineType=qml\nThemeName=kwin4_decoration_qml_plastik"
        ],
    }

    for themeName, themeSettings in kwinThemes.items():
        if theme == themeName:
            query = "PluginLib"
            with open(kwinRC, mode='r', encoding='utf-8') as search:
                for line in search:
                    line = line.rstrip()
                    if line.startswith(query):
                        search.close()
                        break
            kwinFileRead = open(kwinRC).read()
            kwinFileRead = kwinFileRead.replace(line, themeSettings[0])
            kwinFileWrite = open(kwinRC, mode='w', encoding='utf-8')
            kwinFileWrite.write(kwinFileRead)
            kwinFileWrite.close()

            if themeSettings[1]:
                openAuroraerc = open(auroraeRC, mode='w', encoding='utf-8')
                openAuroraerc.write(themeSettings[2])
                openAuroraerc.close()

            logger.writeLog('changeTheme', themeName)
            return True
예제 #12
0
def killKwin():
    kwinPid = subprocess.Popen(["pidof", "-s", "kwin"], stdout=subprocess.PIPE)
    out, err = kwinPid.communicate()
    pidOfKwin = int(out)

    try:
        os.kill(pidOfKwin, 15)
        logger.writeLog('killedKwin')
    except OSError as e:
        print('WARNING: failed os.kill: %s' % e)
        print("Trying SIGKILL")
        logger.writeLog('failedKillingKwin')
        os.kill(pidOfKwin, 9)
        logger.writeLog('killedPlasmaSIGKILL')
예제 #13
0
def killPlasma():
    try:
        KQuitPlasma = subprocess.Popen(["kquitapp", "plasma-desktop"], stdout=subprocess.PIPE)
        out, err = KQuitPlasma.communicate()
        logger.writeLog('killedPlasma')
    except OSError as e:
        print('WARNING: failed os.kill: %s' % e)
        print("Trying SIGKILL")
        plasmaPid = subprocess.Popen(["pidof", "-s", "plasma-desktop"], stdout=subprocess.PIPE)
        out, err = plasmaPid.communicate()
        pidOfPlasma = int(out)
        logger.writeLog('failedKillingPlasma')
        os.kill(pidOfPlasma, 9)
        logger.writeLog('killedPlasmaSIGKILL')
예제 #14
0
def killKwin():
    kwinPid = subprocess.Popen(["pidof", "-s", "kwin"], stdout=subprocess.PIPE)
    out, err = kwinPid.communicate()
    pidOfKwin = int(out)

    try:
        os.kill(pidOfKwin, 15)
        logger.writeLog('killedKwin')
    except OSError as e:
        print('WARNING: failed os.kill: %s' % e)
        print("Trying SIGKILL")
        logger.writeLog('failedKillingKwin')
        os.kill(pidOfKwin, 9)
        logger.writeLog('killedPlasmaSIGKILL')
예제 #15
0
def killPlasma():
    try:
        KQuitPlasma = subprocess.Popen(["kquitapp", "plasma-desktop"],
                                       stdout=subprocess.PIPE)
        out, err = KQuitPlasma.communicate()
        logger.writeLog('killedPlasma')
    except OSError as e:
        print('WARNING: failed os.kill: %s' % e)
        print("Trying SIGKILL")
        plasmaPid = subprocess.Popen(["pidof", "-s", "plasma-desktop"],
                                     stdout=subprocess.PIPE)
        out, err = plasmaPid.communicate()
        pidOfPlasma = int(out)
        logger.writeLog('failedKillingPlasma')
        os.kill(pidOfPlasma, 9)
        logger.writeLog('killedPlasmaSIGKILL')
예제 #16
0
def deleteDir(directory):
    fullPathXdg = homeDir + "/.config/user-dirs.dirs"
    if os.path.exists(fullPathXdg):
        try:
           with open(fullPathXdg) as xdgConfig:
              homeDirsNames = [line.rstrip('\n') for line in xdgConfig if not line.startswith("#")]
              homeDirDic = {}
              for dirName in homeDirsNames:
                  homeDirDic[dirName.split('=')[0]] = ''.join(dirName.split('=')[1:])
        except IOError:
           print("Couldn't parse the " + fullPathXdg + " configuration file.")
           logger.writeLog('couldntParseXDG', fullPathXDG)
           
    for xdgVar, homeDirValue in homeDirDic.items():
        if xdgVar == directory:
            if homeDirValue != "\"$HOME/\"":
                fullPath = ''.join(homeDirValue.replace("$HOME", homeDir).split("\"")[1:])
                if os.path.exists(fullPath):
                    if os.listdir(fullPath) == []:
                        os.rmdir(fullPath)
                        logger.writeLog("removedDir", fullPath)   
                    else:
                        logger.writeLog("dirNotEmpty", fullPath)
                else:
                    logger.writeLog('dirNotExists', fullPath)
                os.system('xdg-user-dirs-update --set ' + directory.partition('XDG_')[-1].rpartition('_DIR')[0] + ' $HOME/')
            else:
                fullPath = homeDirValue.replace("$HOME", homeDir)
                if os.path.exists(fullPath):
                    if os.listdir(fullPath) == []:
                        os.rmdir(fullPath)
                        logger.writeLog("removedDir", fullPath)   
                    else:
                        logger.writeLog("dirNotEmpty", fullPath)
                else:
                    logger.writeLog('dirNotExists', fullPath)             
예제 #17
0
def startPlasma():
    subprocess.Popen(["plasma-desktop"], stdout=subprocess.PIPE)
    logger.writeLog('startPlasma')
예제 #18
0
def startKwin():
    subprocess.Popen(["dbus-send", "--dest=org.kde.kwin", "/KWin", "org.kde.KWin.reloadConfig"], stdout=subprocess.PIPE)
    logger.writeLog('startKwin')
예제 #19
0
def launchAppearance():
    logger.writeLog("launchCustomize")
    Popen(["lxappearance"])
    return True
예제 #20
0
def launchSystemSettings():
    logger.writeLog("launchSystemSettings")
    Popen(["systemsettings"])
    return True
예제 #21
0
def startPlasma():
    subprocess.Popen(["plasma-desktop"], stdout=subprocess.PIPE)
    logger.writeLog('startPlasma')
예제 #22
0
def launchAppearance():
    logger.writeLog("launchCustomize")
    Popen(["lxappearance"])
    return True
예제 #23
0
def launchSystemSettings():
    logger.writeLog("launchSystemSettings")
    Popen(["systemsettings"])
    return True
예제 #24
0
def changeWallpaperOpenbox(wallpaperChoice, wallpaperOptions):
    for wallpaperName, wallpaperPath in wallpaperOptions.items():
        if wallpaperChoice == wallpaperName:
            setWallpaper = subprocess.Popen(["nitrogen", "--set-scaled", "--save", wallpaperPath], stdout=subprocess.PIPE)
            setWallpaper.wait()
            logger.writeLog("changedWallpaper", wallpaperName)
예제 #25
0
def launchHelp():
    logger.writeLog("launchHelp")
    open_('http://manjaro.org')
    return True
예제 #26
0
def launchHelp():
    logger.writeLog("launchHelp")
    open_('http://manjaro.org')
    return True