Results 1 to 10 of 10

Thread: Command to refresh main menu in unity

  1. #1
    Join Date
    Dec 2008
    Location
    South Carolina
    Beans
    113
    Distro
    Ubuntu 13.04 Raring Ringtail

    Command to refresh main menu in unity

    Hello everyone!
    I have created a small script that adds a .desktop file for a menu entry. However in order for it to work I must log out and back in after the script is finished in order to refresh the main menu. Is there not a command I could add to the end of my script that will refresh the menu for me automatically? I've done a few Google searches and came up empty handed. Thanks in advanced for your help.

    -NCB
    Last edited by Cfhs_1; May 10th, 2013 at 01:46 AM. Reason: Thread marked as SOLVED
    Dell Vostro, 6GB RAM, Intel Core i5 (Sandy Bridge) @ 2.5GHz, ubuntu 13.04 Raring Ringtail

  2. #2
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Command to refresh main menu in unity

    I don't know how relevant or helpful, but your post rang a bell and I searched through my notes and found
    after you edit a .desktop file you may need to refresh the desktop cache with
    sudo dpkg-reconfigure python-gmenu
    Related post...
    http://ubuntuforums.org/showthread.php?t=1667513
    Last edited by stinkeye; May 6th, 2013 at 05:12 PM.

  3. #3
    Join Date
    Dec 2008
    Location
    South Carolina
    Beans
    113
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Command to refresh main menu in unity

    Thanks for your quick reply, however this doesn't seem to be the solution I'm looking for. It just gives an error. (python-gmenu is not installed by default in ubuntu 13.04) I need this script to work on fresh installations of ubuntu without having to install extra packages first.
    Dell Vostro, 6GB RAM, Intel Core i5 (Sandy Bridge) @ 2.5GHz, ubuntu 13.04 Raring Ringtail

  4. #4
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Command to refresh main menu in unity

    Will reloading unity do it???
    Code:
    setsid unity

  5. #5
    Join Date
    Dec 2008
    Location
    South Carolina
    Beans
    113
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Command to refresh main menu in unity

    Quote Originally Posted by stinkeye View Post
    Will reloading unity do it???
    Code:
    setsid unity
    Just gave it a try. Didn't work.
    Dell Vostro, 6GB RAM, Intel Core i5 (Sandy Bridge) @ 2.5GHz, ubuntu 13.04 Raring Ringtail

  6. #6
    Join Date
    Dec 2008
    Location
    South Carolina
    Beans
    113
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Command to refresh main menu in unity

    Bump!

    Anyone else have any suggestions? There HAS to be a way to do this.
    Dell Vostro, 6GB RAM, Intel Core i5 (Sandy Bridge) @ 2.5GHz, ubuntu 13.04 Raring Ringtail

  7. #7
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Command to refresh main menu in unity

    Hi again.
    As a test I created a mytest-launcher.desktop file and placed it in ~/.local/share/applications
    and it shows up immediately when searching in the dash home and in the applications menu.
    Last edited by stinkeye; May 7th, 2013 at 08:22 PM.

  8. #8
    Join Date
    Dec 2008
    Location
    South Carolina
    Beans
    113
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Command to refresh main menu in unity

    Quote Originally Posted by stinkeye View Post
    Hi again.
    As a test I created a mytest-launcher.desktop file and placed it in ~/.local/share/applications
    and it shows up immediately when searching in the dash home and in the applications menu.
    I tried it, and can confirm that unity will automatically detect .desktop files in $HOME./local/share/applications I've went back and looked at my code again and discovered something. It seems that fresh installations don't have the applications folder under $HOME/.local/share. So in my script it is created with the mkdir command then my .desktop file is copied there. Something about this folder being created requires a logout/login before unity will "see" it or load .desktop files from there. The applications folder is created with standard user permissions and not root, so that can't be the issue. I believe I have pin pointed the issue, I'm just not sure how to fix it. Any ideas?

    -NCB
    Dell Vostro, 6GB RAM, Intel Core i5 (Sandy Bridge) @ 2.5GHz, ubuntu 13.04 Raring Ringtail

  9. #9
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Command to refresh main menu in unity

    I came across this command using gsettings to add a .desktop file to the launcher you may be able to use.
    Code:
    gsettings set com.canonical.Unity.Launcher favorites "$(gsettings get com.canonical.Unity.Launcher favorites | sed "s/, *'yourapp.desktop' *//g" | sed "s/'yourapp.desktop' *, *//g" | sed -e "s/]$/, 'yourapp.desktop']/")"
    I can add a .desktop file from ~/.local/share/applications to the launcher,
    even when the .desktop file does not show with a dash search.

    eg I created a new user account and created the directory ~/.local/share/applications and placed
    the mytest.desktop file in it.
    Searched the dash. No results.
    Ran the command...
    Code:
    gsettings set com.canonical.Unity.Launcher favorites "$(gsettings get com.canonical.Unity.Launcher favorites | sed "s/, *'mytest.desktop' *//g" | sed "s/'mytest.desktop' *, *//g" | sed -e "s/]$/, 'mytest.desktop']/")"
    ...and it shows up immediately in the launcher.

  10. #10
    Join Date
    Dec 2008
    Location
    South Carolina
    Beans
    113
    Distro
    Ubuntu 13.04 Raring Ringtail

    Cool Re: Command to refresh main menu in unity

    Quote Originally Posted by stinkeye View Post
    I came across this command using gsettings to add a .desktop file to the launcher you may be able to use.
    Code:
    gsettings set com.canonical.Unity.Launcher favorites "$(gsettings get com.canonical.Unity.Launcher favorites | sed "s/, *'yourapp.desktop' *//g" | sed "s/'yourapp.desktop' *, *//g" | sed -e "s/]$/, 'yourapp.desktop']/")"
    I can add a .desktop file from ~/.local/share/applications to the launcher,
    even when the .desktop file does not show with a dash search.

    eg I created a new user account and created the directory ~/.local/share/applications and placed
    the mytest.desktop file in it.
    Searched the dash. No results.
    Ran the command...
    Code:
    gsettings set com.canonical.Unity.Launcher favorites "$(gsettings get com.canonical.Unity.Launcher favorites | sed "s/, *'mytest.desktop' *//g" | sed "s/'mytest.desktop' *, *//g" | sed -e "s/]$/, 'mytest.desktop']/")"
    ...and it shows up immediately in the launcher.
    That's exactly what I needed! It's perfect! I was just about to give up hope! Thank you soo much!
    Dell Vostro, 6GB RAM, Intel Core i5 (Sandy Bridge) @ 2.5GHz, ubuntu 13.04 Raring Ringtail

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •