Fix weird flux menu

2017-05-03 1 min read Learning Linux

Some distro’s just add all the items under single menu and thus the menu itself becomes unusable because of the number of items in the submenu and this I did not like and hence ceated this simply python script to fix that. For using the script, back up you “menu” file, redirect the output of this script to ‘menu’ file again.

 

#!/bin/python

F = open("~/.fluxbox/menu", "r")
count=0
mkc=1
started=0

for line in F:
    print line.rstrip()

    if '[submenu]' in line.lower() and started == 1:
        print '[end]'

    if '[end]'  in line.lower():
        count=0
        mkc=1
        if started > 0:
             started=0
             # print "Count is {}".format(count)
             # print "Started is {}".format(started)
             print '[end]'
    if '[exec]'  in line.lower():
        if count > 15 :
            if started > 0:
                started=0
                print '[end]'
                # print "Count is {}".format(count)
                # print "Started is {}".format(started)
            print '[submenu] ({})'.format(mkc)
            started=1
            mkc+=1
            count=0
        # print count
        count+=1
comments powered by Disqus