Wine menus - rebuilding, deleting

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Gert van den Berg

Wine menus - rebuilding, deleting

Post by Gert van den Berg » Sun Feb 08, 2009 3:09 am

Hi

I have a few questions about Wine's menu handling:
1. Is there some kind of command that will build a wine menu based on
all the files in the standard locations (Start menu and Desktop)? This
would be useful for rebuilding the Wine menu after deleting it. (Since
deleting the menu entries belonging to a single prefix is not easy)
winemenubuilder seem to take only single shortcuts as parameters (and
is does not give help on any obvious paramenters (/? -h --help))
according to http://wiki.winehq.org/winemenubuilder
2. Is there a way to delete only a single WINEPREFIX's menu entries?
(The FAQ's methods is a bit of a sledgehammer)
3. If there is no obvious ways to do any of the above, do anyone have
some scripts to assist with these tasks?

I have changed distributions from Gentoo x86 to Ubuntu x86_64 and have
copied several WINEPREFIXes (Actually most of my $HOME, except for
some hidden files, which it though might break some things..) over.
(They seem to work fine except for some weirdness mostly involving the
Gecko upgrade (for some reason I only had the old version in
/usr/share/wine/gecko))

Gert

vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Wine menus - rebuilding, deleting

Post by vitamin » Sun Feb 08, 2009 12:24 pm

Gert van den Berg wrote:1. Is there some kind of command that will build a wine menu based on all the files in the standard locations (Start menu and Desktop)?
I've used this to rebuild menu structure:

Code: Select all

export WINEPREFIX=~/.wine; find $WINEPREFIX/drive_c/ -name "*.lnk" -exec wine winemenubuilder '{}' \;
Gert van den Berg wrote:2. Is there a way to delete only a single WINEPREFIX's menu entries?
Just look for entries containing your WINEPREFIX.

Gert van den Berg

Wine menus - rebuilding, deleting

Post by Gert van den Berg » Mon Feb 09, 2009 12:16 pm

On Sun, Feb 8, 2009 at 7:24 PM, vitamin <wineforum-user@winehq.org> wrote:
Gert van den Berg wrote:
1. Is there some kind of command that will build a wine menu based on all the files in the standard locations (Start menu and Desktop)?
I've used this to rebuild menu structure:

Code:

export WINEPREFIX=~/.wine; find $WINEPREFIX/drive_c/ -name "*.lnk" -exec wine winemenubuilder '{}' \;
Thanks. I build the following little script below (If someone finds it
useful. It is meant for my ~/.wine-* type of prefixes and ignores the
Desktop and icons. It does not do the standard .wine directory,
although it should be easy to add)

If I have some time I might do a Perl script that can handle separate
prefixes. (I would probably need to look inside the .desktop files...)
This should have the advantage of not breaking edits (such as using a
patched Wine-git for Warcraft...)

#!/bin/sh

find="/usr/bin/find"
wine="wine"
rm="/bin/rm"

# Clears menus - leaves desktop and icons alone
"$rm" -f $HOME/.config/menus/applications-merged/wine*
"$rm" -rf $HOME/.local/share/applications/wine


# Rebuild Start Menu for all prefixes starting with ".wine-"
for prefix in "$HOME/".wine-*; do
WINEPREFIX="$prefix"
export WINEPREFIX
"$find" "$WINEPREFIX/drive_c/" -name '*/Start Menu/*.lnk'
-exec "$wine" winemenubuilder '{}' \; 2> /dev/null
done

Gert van den Berg

Wine menus - rebuilding, deleting

Post by Gert van den Berg » Mon Feb 09, 2009 12:19 pm

On Mon, Feb 9, 2009 at 7:00 PM, Gert van den Berg <wine-users@mohag.net> wrote:
"$find" "$WINEPREFIX/drive_c/" -name '*/Start Menu/*.lnk' -exec "$wine" winemenubuilder '{}' \; 2> /dev/null
Should be -wholename, which probably means that it requires GNU find,
which might be hard to find on non-Linux operating systems...

Gert

IntuitiveNipple
Newbie
Newbie
Posts: 1
Joined: Mon May 04, 2009 8:04 am

Post by IntuitiveNipple » Mon May 04, 2009 8:46 am

Thanks for the work you did on this - I needed it to clean out some messy entries in Gnome after moving a $HOME structure to a newer Ubuntu release - the original menus had their titles messed up in ~/.local/share/applications/

I rewrote your script to use shell constructs instead of 'find'. I've copied it here for others to play with.

Code: Select all

#!/bin/sh

wine="wine"
rm="/bin/rm"

iterate_start_menu ()
{
 local menu_dir
 local oldIFS
 menu_dir=$1
 # don't use space as field-separator otherwise "paths with spaces" will fail to parse correctly
 oldIFS=$IFS
 IFS=?
 echo "menu_dir=${menu_dir}"
 # add a trailing slash to the directory name, then the glob wildcard
 for entry in ${menu_dir}/*; do
  if [ -f "$entry" ]; then
	echo "Link: $entry";
    "$wine" winemenubuilder "$entry" 2>/dev/null
  elif [ -d "$entry" ]; then
	echo "Directory: $entry";
	iterate_start_menu "$entry"
  else
	echo "Empty: $entry";
  fi
 done

 IFS=$oldIFS
}

# Delete current user-defined wine menus
"$rm" -f $HOME/.config/menus/applications-merged/wine*
"$rm" -rf $HOME/.local/share/applications/wine

# Rebuild Start Menu for all prefixes starting with ".wine-" or ".wine" itself
for prefix in "$HOME/".wine-* "$HOME/".wine; do
 WINEPREFIX="$prefix"
 export WINEPREFIX
 # do not use a trailing / at the end of the directory name
 iterate_start_menu "${WINEPREFIX}/drive_c/windows/profiles/*/Start Menu"
done

f.gruber
Level 1
Level 1
Posts: 7
Joined: Mon Apr 05, 2010 5:02 am

Post by f.gruber » Tue Dec 13, 2011 1:28 pm

Hi,

I tried to renew all my wine Folders in the K Menu. At first I deleted the "Program" Folder.

After executing your script I realize that it has created a lot of files in

Code: Select all

$HOME/.config/menus/applications-merged
and in

Code: Select all

$HOME/.local/share/applications/wine
I think there are also new files in this folder:

Code: Select all

$HOME/.kde4/share/applnk
But in the K Menu I cannot find any item to start the wine programs even after running

Code: Select all

kbuildsycoca4
This happens under openSuse 12.1 with KDE 4.7.3 and wine 1.3.30
Please can anyone help me.

Locked