Mint-fm2

From Linux Mint

Jump to: navigation, search

Contents

What is Mint-FM2

Mint-FM2 is the autogenerating and autoupdating menu system for the Linux Mint Fluxbox Community Edition. Mint-FM2 also provides an exit dialog and settings for log in and log out system sounds.

Features

  • Autogenerates the Fluxbox menu based on freedesktop.org compliant .desktop files located in /usr/share/applications/.
  • Autoupdates the Fluxbox menu when a new .desktop file is created (installation) or when an existing one is deleted (uninstallation).
  • Allows enabling or disabling of icons in the Fluxbox menu.
  • Preserves changes made by the user to the menu.
  • Provides a file ~/.fluxbox/custom-menu-entries in which the user may set up custom menu entries that are preserved through menu regeneration.
  • Language localization is supported provided translations are available. Menu entry translations are obtained from the .desktop file. The root menu translations are provided by Mint-FM2. Please help translate Mint-FM2 here: http://forums.linuxmint.com/viewtopic.php?f=43&t=21210
  • Provides an exit dialog for Fluxbox in which no administrator user password is required for shutdown, restart, hibernate or suspend.
  • Provides a script and settings for log in and log out system sounds.
  • Ignores .desktop files that are not meant to be shown in the menu.

Configuration

The Mint-FM2 configurations are stored in ~/.mint-fm2/mint-fm2.conf. Available settings are:

  • Icons: This is a boolean setting (true or false) defining whether icons are enabled or disabled in the Fluxbox menu.
Example
Icons: false
  • IconTheme: This setting defines the default icon theme to be used in the Fluxbox menu. The value should be the full path to the directory containing the icon theme.
Example
IconTheme: /usr/share/icons/OxygenRefit2-green-version-mintfb
  • Login and Logout: These settings define the system sounds to be used for log in and log out.
Example
Login: /usr/share/sounds/mintfb-login.wav
Logout: /usr/share/sounds/mintfb-logout.wav

Disabling login and logout sounds can be done by commenting out the above lines with a "#" or by deleting them completely from the file.

Note that there should be a space between the setting name and the value.

Enabling or disabling menu icons can be done in the Fluxbox CE version of mintDesktop in the System Tweaks tab.

Restoring the default menu

This can easily be done by enabling or disabling menu icons in mintDesktop or deleting the existing Fluxbox menu file ~/.fluxbox/menu, then logging out and logging back in. Note that the entries in ~/.fluxbox/custom-menu-entries are not affected by this.

Customizing the menu

  • The Fluxbox Wiki on how to edit the menu
  • Menu entries can be added in ~/.fluxbox/custom-menu-entries. These entries are loaded automatically into the Fluxbox menu. Entries in this file are not affected by menu regeneration.
  • The autogenerated menu is located in ~/.mint-fm2/submenus/ separated into files for each submenu. These files can be edited manually and the changes will be preserved until the menu is regenerated. The same applies to the main menu file ~/.fluxbox/menu. Note that enabling or disabling menu icons regenerates the menu files.

How It Works

This information is only required if you would like to know how Mint-FM2 works. The above information should be enough for normal use. To delve deeper into how it works, I would recommend looking at the scripts. Here I will only explain the general principles. Suggestions and corrections to improve the code are most welcome.

Most of Mint-FM2 is a collection of scripts written in bash. The default location for installation of these scripts is /usr/lib/linuxmint/mint-fm2. The exit dialog (ciao) is written in Python with a GTK Glade interface.

Mint-FM2 is made up of 2 parts; the parts run as root and the parts run as the user.

Scripts run as root

This is basically a daemon that watches for newly installed and recently uninstalled applications, and user requests to shutdown, reboot, hibernate or suspend. The root daemon script is /usr/lib/linuxmint/mint-fm2/mfmrootdaemon and it uses inotify to watch for changes.

When an application is installed or uninstalled, mfmrootdaemon creates a trigger file in ~/.mint-fm2/triggers for each user on the system. If the user's Mint-FM2 daemon is running, the menu is updated automatically according to the trigger file created. If it is not running or if the user is not logged in at the time of the change, the menu will be updated when the user logs in.

mfmrootdaemon also watches /tmp/mint-fm2-trigger. All users have write permissions to this folder. When a user selects an action that requires root privileges, a trigger file is created here. mfmrootdaemon then runs the appropriate command, depending on the trigger, as root. This results in the user not being forced to provide an administrator password for these actions.

Mint-FM2 can be controlled by a Debian compliant upstart script. i.e. You can start or stop the root daemon using

sudo /etc/init.d/mint-fm2 [start|stop|restart]

Scripts run as the user

This part of Mint-FM2 forms the bulk of the scripts.

When a user logs in, a launcher script is run (by ~/.fluxbox/startup) which loads all the system variables required and runs some checks to ensure that only one instance of Mint-FM2 is started per user and that all the files and folders required by Mint-FM2 are present in ~/.mint-fm2. If not, default files and folders are created. It then checks for pending updates to the menu (e.g. if an application was installed by another user while the current user was logged out) and updates the menu if required. If no Fluxbox menu is present, it autogenerates a new menu. Finally, it launches /usr/lib/linuxmint/mint-fm2/mfmuserdaemon, the user daemon.

mfmuserdaemon watches the trigger directory, ~/.mint-fm2/triggers. When a new application is installed/uninstalled and detected by mfmrootdaemon, mfmrootdaemon creates a trigger which specifies which menu entry is to be created/deleted by mfmuserdaemon, which does just that when it detects the trigger. mfmuserdaemon also uses inotify to monitor the trigger folder.

Menu entries created by mfmuserdaemon have a commented tag after each entry. This enables mfmuserdaemon to tie an entry to the .desktop file from which it was created and remove the entry when the application is uninstalled.


The final part is the exit dialog named 'ciao'. This is written in Python and has an interface built using the Glade libraries. This provides the user with the common exit options. For the options that require root privileges, ciao simply creates the appropriate trigger in /tmp/mint-fm2-trigger which is then detected by mfmrootdaemon and the appropriate action is then performed as root.

This about explains in a nutshell how Mint-FM2 works. If you are interested in the code, simply look at the scripts in /usr/lib/linuxmint/mint-fm2/ and the files in ~/.mint-fm2/. They are all simple bash scripts and text files except for ciao which is in Python. Alternatively you may download the source package here: http://packages.linuxmint.com/pool/main/m/mint-fm2/

Personal tools