/usr/sbin/gnome-menus-blacklist is in gnome-menus 3.13.3-11ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #! /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))
|