HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //sbin/gnome-menus-blacklist
#! /usr/bin/python3

sourcedir = "/usr/share/applications"
destdir = "/usr/share/gnome/applications"
blacklist_file = "/etc/gnome/menus.blacklist"

import sys, os

# Parse blacklist file
blacklist = []
try:
    with open(blacklist_file, 'r', encoding='utf_8') as fp:
        for l in fp.readlines():
            l = l.strip()
            if l.startswith("#"):
                continue
            blacklist.append(l)
except IOError:
    sys.stderr.write("Warning: %s cannot be opened\n"%blacklist_file)

# Built the list of files to work on
sourcefiles = []
for root, dirs, files in os.walk (sourcedir):
    reldir = root[len(sourcedir)+1:]
    for f in files:
        relfile = os.path.join (reldir, f)
        if relfile.endswith(".desktop") and (f in blacklist or relfile in blacklist):
            sourcefiles.append(relfile)

# Remove obsolete files
for root, dirs, files in os.walk (destdir, topdown=False):
    reldir = root[len(destdir)+1:]
    for f in files:
        relfile = os.path.join (reldir, f)
        if f.endswith(".desktop") and relfile not in sourcefiles:
            os.remove (os.path.join (destdir, relfile))
    if reldir:
        try:
            os.rmdir (root)
        except OSError:
            pass

# Now process the files
for f in sourcefiles:
    sourcefile = os.path.join (sourcedir, f)
    destfile = os.path.join (destdir, f)
    absdir = os.path.dirname (destfile)

    # The mtime is used as a flag to check if the file has changed
    source_time = int (os.stat (sourcefile).st_mtime)
    try:
        dest_time = int (os.stat (destfile).st_mtime)
    except OSError:
        dest_time = 0
    if source_time == dest_time:
        continue

    # Copy file, adding a NoDisplay flag
    if not os.path.isdir (absdir):
        os.makedirs (absdir)
    with open(destfile, 'wt', encoding='utf_8') as fp_out:
        with open(sourcefile, 'rt', encoding='utf_8') as fp_in:
            for l in fp_in.readlines():
                if l.startswith ("NoDisplay="):
                    continue
                fp_out.write(l)
        if not l.endswith ("\n"):
            fp_out.write("\n")
        fp_out.write("NoDisplay=true\n")

    # Set mtime so that the file is not touched unless it has changed
    os.utime (destfile, (source_time, source_time))