File indexing completed on 2024-12-01 06:42:32

0001 #!/usr/bin/env python3
0002 
0003 """
0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 SPDX-FileCopyrightText: 2022 Alois Wohlschlager <alois1@gmx-topmail.de>
0006 """
0007 
0008 from pprint import pprint
0009 import os
0010 import shutil
0011 import sys
0012 
0013 aliases = {
0014     "akregator": ["org.kde.akregator"],
0015     "alligator": ["org.kde.alligator"],
0016     "amarok": ["org.kde.amarok"],
0017     "anydesk": ["com.anydesk.Anydesk"],
0018     "ardour": ["org.ardour.Ardour"],
0019     "ark": ["org.kde.ark"],
0020     "artikulate": ["org.kde.artikulate"],
0021     "atom": ["io.atom.Atom"],
0022     "audacity": ["org.audacityteam.Audacity"],
0023     "blender": ["org.blender.Blender"],
0024     "blinken": ["org.kde.blinken"],
0025     "bluefish": ["nl.openoffice.bluefish"],
0026     "bomber": ["org.kde.bomber"],
0027     "bovo": ["org.kde.bovo"],
0028     "brackets": ["io.brackets.Brackets"],
0029     "cantor": ["org.kde.cantor"],
0030     "claws-mail": ["org.claws_mail.Claws-Mail"],
0031     "converseen": ["net.fasterland.converseen"],
0032     "darktable": ["org.darktable.Darktable"],
0033     "diffuse": ["io.github.mightycreak.Diffuse"],
0034     "digikam": ["org.kde.digikam"],
0035     "elisa": ["org.kde.elisa"],
0036     "falkon": ["org.kde.falkon"],
0037     "filezilla": ["org.filezillaproject.Filezilla"],
0038     "fontforge": ["org.fontforge.FontForge"],
0039     "gimp": ["org.gimp.GIMP"],
0040     "goodvibes": ["io.gitlab.Goodvibes"],
0041     "gpodder": ["org.gpodder.gpodder"],
0042     "granatier": ["org.kde.granatier"],
0043     "gtkhash": ["org.gtkhash.gtkhash"],
0044     "gwenview": ["org.kde.gwenview"],
0045     "haguichi": ["com.github.ztefn.haguichi"],
0046     "handbrake": ["fr.handbrake.ghb"],
0047     "homebank": ["fr.free.Homebank"],
0048     "inkscape": ["org.inkscape.Inkscape"],
0049     "jdownloader": ["org.jdownloader.JDownloader"],
0050     "joplin": ["net.cozic.joplin_desktop"],
0051     "juk": ["org.kde.juk"],
0052     "kalgebra": ["org.kde.kalgebra"],
0053     "kalzium": ["org.kde.kalzium"],
0054     "kamoso": ["org.kde.kamoso"],
0055     "kanagram": ["org.kde.kanagram"],
0056     "kapman": ["org.kde.kapman"],
0057     "katomic": ["org.kde.katomic"],
0058     "kblackbox": ["org.kde.kblackbox"],
0059     "kblocks": ["org.kde.kblocks"],
0060     "kbreakout": ["org.kde.kbreakout"],
0061     "kbruch": ["org.kde.kbruch"],
0062     "kcachegrind": ["org.kde.kcachegrind"],
0063     "kdenlive": ["org.kde.kdenlive"],
0064     "kdevelop": ["org.kde.kdevelop"],
0065     "kdiamond": ["org.kde.kdiamond"],
0066     "kdiff3": ["org.kde.kdiff3"],
0067     "kfind": ["org.kde.kfind"],
0068     "kfourinline": ["org.kde.kfourinline"],
0069     "kgeography": ["org.kde.kgeography"],
0070     "kget": ["org.kde.kget"],
0071     "khangman": ["org.kde.khangman"],
0072     "kig": ["org.kde.kig"],
0073     "kile": ["org.kde.kile"],
0074     "kiriki": ["org.kde.kiriki"],
0075     "kiten": ["org.kde.kiten"],
0076     "kjumpingcube": ["org.kde.kjumpingcube"],
0077     "kmplot": ["org.kde.kmplot"],
0078     "knights": ["org.kde.knights"],
0079     "kolf": ["org.kde.kolf"],
0080     "kolourpaint": ["org.kde.kolourpaint"],
0081     "kontact": ["org.kde.kontact"],
0082     "konversation": ["org.kde.konversation"],
0083     "kopete": ["org.kde.kopete"],
0084     "kphotoalbum": ["org.kde.kphotoalbum"],
0085     "krdc": ["org.kde.krdc"],
0086     "krename": ["org.kde.krename"],
0087     "kronometer": ["org.kde.kronometer"],
0088     "kruler": ["org.kde.kruler"],
0089     "ksirk": ["org.kde.ksirk"],
0090     "kstars": ["org.kde.kstars"],
0091     "kteatime": ["org.kde.kteatime"],
0092     "ktimetracker": ["org.kde.ktimetracker"],
0093     "ktorrent": ["org.kde.ktorrent"],
0094     "ktouch": ["org.kde.ktouch"],
0095     "ktrip": ["org.kde.ktrip"],
0096     "kuiviewer": ["org.kde.kuiviewer"],
0097     "kwrite": ["org.kde.kwrite"],
0098     "kxstitch": ["org.kde.kxstitch"],
0099     "labplot": ["org.kde.labplot2"],
0100     "leocad": ["org.leocad.LeoCAD"],
0101     "libreoffice-base": ["org.libreoffice.LibreOffice.base"],
0102     "libreoffice-calc": ["org.libreoffice.LibreOffice.calc"],
0103     "libreoffice-draw": ["org.libreoffice.LibreOffice.draw"],
0104     "libreoffice-impress": ["org.libreoffice.LibreOffice.impress"],
0105     "libreoffice-math": ["org.libreoffice.LibreOffice.math"],
0106     "libreoffice-startcenter": ["org.libreoffice.LibreOffice.startcenter"],
0107     "libreoffice-writer": ["org.libreoffice.LibreOffice.writer"],
0108     "lokalize": ["org.kde.lokalize"],
0109     "massif-visualizer": ["org.kde.massif-visualizer"],
0110     "masterpdfeditor": ["net.codeindustry.MasterPDFEditor"],
0111     "mendeleydesktop": ["com.elsevier.MendeleyDesktop"],
0112     "minitube": ["org.tordini.flavio.Minitube"],
0113     "minuet": ["org.kde.minuet"],
0114     "mpv": ["io.mpv.Mpv"],
0115     "nota": ["org.kde.nota"],
0116     "okteta": ["org.kde.okteta"],
0117     "okular": ["org.kde.okular"],
0118     "picmi": ["org.kde.picmi"],
0119     "q4wine": ["ua.org.brezblock.q4wine"],
0120     "qbittorrent": ["org.qbittorrent.qBittorrent"],
0121     "qelectrotech": ["org.qelectrotech.QElectroTech"],
0122     "rosegarden": ["com.rosegardenmusic.rosegarden"],
0123     "scribus": ["net.scribus.Scribus"],
0124     "skanlite": ["org.kde.skanlite"],
0125     "skrooge": ["org.kde.skrooge"],
0126     "smartgit": ["com.syntevo.SmartGit"],
0127     "smplayer": ["info.smplayer.SMPlayer"],
0128     "steam": ["com.valvesoftware.Steam"],
0129     "sublime-merge": ["com.sublimemerge.App"],
0130     "sublime-text": ["com.sublimetext.Three"],
0131     "telegram": ["org.telegram.desktop"],
0132     "texstudio": ["org.texstudio.TeXstudio"],
0133     "umbrello": ["org.kde.umbrello"],
0134     "viber": ["com.viber.Viber"],
0135     "vlc": ["org.videolan.VLC"],
0136     "vvave": ["org.kde.vvave"],
0137     "wine": ["org.winehq.Wine"],
0138 }
0139 
0140 SRCDIR = sys.argv[1]
0141 BINDIR = sys.argv[2]
0142 
0143 shutil.rmtree(BINDIR, ignore_errors=True)
0144 
0145 created_symlinks = dict()
0146 
0147 for dirpath, _, filenames in os.walk(os.path.join(SRCDIR, "apps")):
0148     outpath = os.path.join(BINDIR + dirpath[len(SRCDIR):])
0149     os.makedirs(outpath)
0150     for file in filenames:
0151         if file[-4:] == ".svg":
0152             base = file[:-4]
0153             if base not in created_symlinks.keys():
0154                 created_symlinks[base] = dict()
0155             if base in aliases:
0156                 for alias in aliases[base]:
0157                     os.symlink(file, os.path.join(outpath, alias + ".svg"))
0158                     if alias not in created_symlinks[base].keys():
0159                         created_symlinks[base][alias] = []
0160                     created_symlinks[base][alias].append(int(outpath.split('/')[-1]))
0161 
0162 print('Symlinking application icons to their Flatpak IDs:')
0163 pprint(created_symlinks)