StokeBloke.com

Archive for May, 2013

Pretty Format Json in Emacs

Wednesday, May 29th, 2013

To format json data in emacs, its best to use the python module ‘json.tool’. Simply make a function to wrap up the whole buffer and format it.

(defun json-format ()
  (interactive)
  (save-excursion
    (shell-command-on-region (point-min) (point-max) "python -m json.tool" (buffer-name) t)
    )
  )

Xfce menu customisation guide

Monday, May 27th, 2013

I use Xfce all the time at home and I rdesktop into loads of different computers. Over time I have created many desktop entries for rdesktop connections to many different computers.

E.g.

[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Exec=rdesktop -d ; -z -u  -g 1670x1025  -k de
Icon=chardevice
StartupNotify=false
Categories=Network
Name=RDesktop(hostname)
Comment=RDesktop(hostname)

Each entry I created needed to be created in the ~/.local/share/applications directory. These are then automatically loaded and added to the Network sub menu. (The list of main categories is listed here)

I started to get problems after adding 12+ desktop entries to the Network menu. With the standard Network entries and my custom rdesktop entries it was getting very tall and messy.

I then started to look into if I could move the rdesktop commands into its own submenu separating them out.

I found that I could make general changes to the menu layout via the menu file.   On my distribution its located ~/.config/menus/xfce-applications.menu

Simply create a new submenu

    
      RDesktop
      rdesktop.directory
      
         RDesktop
      
    

and include this in the main Layout section

    
        exo-terminal-emulator.desktop
        exo-file-manager.desktop
        exo-mail-reader.desktop
        exo-web-browser.desktop
        
        RDesktop
        
        Settings
        
        
        
        xfhelp4.desktop
        xfce4-run.desktop
        xfce4-about.desktop
        xfce4-session-logout.desktop
    

The rdesktop.directory entry in the submenu points to a file in the .local/share/desktop-directories/rdesktop.directory desktop file. This mainly defines the menu icon and a few other things. It looks like this

[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Exec=rdesktop
Icon=chardevice
StartupNotify=false
Categories=X-XFCE;RDesktop
Name=RDesktop
Comment=RDesktop

I then updated the individual desktop files to use the new group.

I.e Categories=Network;RDesktop

[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Exec=rdesktop -d ; -z -u  -g 1670x1025  -k de
Icon=chardevice
StartupNotify=false
Categories=RDesktop
Name=RDesktop(hostname)
Comment=RDesktop(hostname)

Dont forget to read http://wiki.xfce.org/howto/customize-menu too.