Author Topic: Need help with Desktop Entry  (Read 909 times)

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Need help with Desktop Entry
« on: October 02, 2011, 07:13:54 AM »
Hi.

AutoKey is available in both GTK and QT. Unlike recordMyDesktop, the AutoKey Desktop Entries for QT and GTK must both be on the same specfile. I know that it should be n the %install section. What I needed to do is distinguish the QT Desktop Entry from the GTK Desktop Entry.

Below is the specfile:

Code: [Select]
# sitelib for noarch packages
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

Name: autokey
Version: 0.71.3
Release: 4
Summary: Desktop automation utility
Group: Accessibility
License: GPLv3
URL: http://autokey.googlecode.com
Source0: http://autokey.googlecode.com/files/%{name}_%{version}.tar.gz
BuildArch: x86_64
BuildRequires: python-xlib
BuildRequires: python-notify
BuildRequires: pygtk2
BuildRequires: pygtk2-libglade
BuildRequires: desktop-file-utils
Requires: autokey-common
Requires: autokey-gtk
Provides: autokey = %{version}-%{release}

%description
AutoKey is a desktop automation utility for Linux and X11. It allows
the automation of virtually any task by responding to typed abbreviations
and hot keys. It offers a full-featured GUI that makes it highly
accessible for novices, as well as a scripting interface offering
the full flexibility and power of the Python language.

%package common
Summary: Desktop automation utility - common data
Group: Accessibility
Requires: python >= 2.6
Provides: autokey = %{version}-%{release}

%description common
This package contains the common data shared between the various front ends.

%package gtk
Summary: AutoKey GTK+ version
Group: Accessibility
Requires: pygtksourceview
Requires: autokey-common = %{version}-%{release}
Provides: autokey = %{version}-%{release}
%description gtk
This package contains the GTK+ front end for autokey

%package qt
Summary: AutoKey QT version
Group: Accessibility
Requires: python-qt4-qscintilla
Requires: autokey-common = %{version}-%{release}
%{?_qt4_version:Requires: qt4 >= %{_qt4_version}}
Provides: autokey = %{version}-%{release}
%description qt
This package contains the QT front end for autokey

%prep
%setup -q


%build
%{__python} setup.py build

%install
rm -rf %{buildroot}
%{__python} setup.py install -O1 --skip-build --root %{buildroot}

desktop-file-validate %{buildroot}/%{_datadir}/applications/autokey-qt.desktop

# remove shebang from python libraries
for lib in $(find %{buildroot}%{python_sitelib}/autokey/ -name "*.py"); do
 sed '/\/usr\/bin\/env/d' $lib > $lib.new &&
 touch -r $lib $lib.new &&
 mv $lib.new $lib
done

%post gtk
update-desktop-database > /dev/null 2>&1 || :

%post qt
update-desktop-database > /dev/null 2>&1 || :

%postun gtk
update-desktop-database > /dev/null 2>&1 || :

%postun qt
update-desktop-database > /dev/null 2>&1 || :

%files

%files common
%doc doc/scripting ACKNOWLEDGMENTS COPYING
# For noarch packages: sitelib
%{python_sitelib}/autokey/common.*
%{python_sitelib}/autokey/configmanager.*
%{python_sitelib}/autokey/daemon.*
%{python_sitelib}/autokey/evdev.*
%{python_sitelib}/autokey/__init__.*
%{python_sitelib}/autokey/interface.*
%{python_sitelib}/autokey/iomediator.*
%{python_sitelib}/autokey/model.*
%{python_sitelib}/autokey/nogui.*
%{python_sitelib}/autokey/scripting.*
%{python_sitelib}/autokey/service.*
%{python_sitelib}/autokey-*.egg-info
%{_datadir}/pixmaps/*

%files gtk
%{python_sitelib}/autokey/gtkui/*
%{python_sitelib}/autokey/gtkapp.*
%{_bindir}/autokey-gtk
%{_datadir}/applications/autokey-gtk.desktop
%{_mandir}/man1/autokey-gtk.1.bz2

%files qt
%{python_sitelib}/autokey/qtui/*
%{python_sitelib}/autokey/qtapp.*
%{_bindir}/autokey-qt
%{_datadir}/applications/autokey-qt.desktop
%{_mandir}/man1/autokey-qt.1.bz2

%changelog

And my desktop entries for QT:
Code: [Select]
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey QT
Comment=Desktop automation utility
Exec=autokey-qt
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=Qt;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

... and Desktop Entry for GTK:
Code: [Select]
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey GTK
Comment=Desktop automation utility
Exec=autokey-gtk
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=GTK;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

My question is, how can I put both desktop entries on the same specfile and have them clearly distinguished as [Desktop Entry] QT and [Desktop Entry] GTK?

Thank you in advance for any help.
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: Need help with Desktop Entry
« Reply #1 on: October 02, 2011, 07:15:21 AM »
By the way, I've successfully packaged autokey but when installing either the qt or the gtk, there's no menu entry for them. This is what I wanted to fix.

And SRPM is available at http://www.ge.tt/8ncDHa7/v/1
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: Need help with Desktop Entry
« Reply #2 on: November 04, 2011, 10:39:16 AM »
Is there a reason you can't define them like this:

Code: [Select]
%define name1 QT
%define name2 GTK

So when they are added one will be added as QT.desktop and another as GTK.desktop
I still don't really understand how the SPEC file works, but it seem logical to me. If that doesn't work is it possible to include both the .desktop files already made in the sources and tell it to install both of them? Somthing like this:

Code: [Select]
mkdir -p %{buildroot}%{_datadir}/applications
install -m 655 QT.desktop %{buildroot}%{_datadir}/applications/QT.desktop

mkdir -p %{buildroot}%{_datadir}/applications
install -m 655 GTK.desktop %{buildroot}%{_datadir}/applications/GTK.desktop
« Last Edit: November 04, 2011, 10:49:33 AM by glamdring »

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: Need help with Desktop Entry
« Reply #3 on: November 04, 2011, 04:48:21 PM »
Yeap, the .desktop sources would be a good way around ... what I am really wondering about is the %install part on the [Desktop Entry] ... how would I go about adding two entries ... I guess what I am asking is are there any obvious identifier that I am missing?
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: Need help with Desktop Entry
« Reply #4 on: November 04, 2011, 05:18:41 PM »
Would this work?

Fill in %define name1 %define name2 with the name of the desktop files.
Code: [Select]
%define name1
%define name2

#QT desktop
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name1}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey QT
Comment=Desktop automation utility
Exec=autokey-qt
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=Qt;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

#GTK desktop
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name2}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey GTK
Comment=Desktop automation utility
Exec=autokey-gtk
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=GTK;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

%files gtk
%{_datadir}/applications/%{name2}.desktop

%files qt
%{_datadir}/applications/%{name1}.desktop

So it would look something like this:
Code: [Select]
# sitelib for noarch packages
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

%define name1 qt
%define name2 gtk

Name: autokey
Version: 0.71.3
Release: 4
Summary: Desktop automation utility
Group: Accessibility
License: GPLv3
URL: http://autokey.googlecode.com
Source0: http://autokey.googlecode.com/files/%{name}_%{version}.tar.gz
BuildArch: x86_64
BuildRequires: python-xlib
BuildRequires: python-notify
BuildRequires: pygtk2
BuildRequires: pygtk2-libglade
BuildRequires: desktop-file-utils
Requires: autokey-common
Requires: autokey-gtk
Provides: autokey = %{version}-%{release}

%description
AutoKey is a desktop automation utility for Linux and X11. It allows
the automation of virtually any task by responding to typed abbreviations
and hot keys. It offers a full-featured GUI that makes it highly
accessible for novices, as well as a scripting interface offering
the full flexibility and power of the Python language.

%package common
Summary: Desktop automation utility - common data
Group: Accessibility
Requires: python >= 2.6
Provides: autokey = %{version}-%{release}

%description common
This package contains the common data shared between the various front ends.

%package gtk
Summary: AutoKey GTK+ version
Group: Accessibility
Requires: pygtksourceview
Requires: autokey-common = %{version}-%{release}
Provides: autokey = %{version}-%{release}
%description gtk
This package contains the GTK+ front end for autokey

%package qt
Summary: AutoKey QT version
Group: Accessibility
Requires: python-qt4-qscintilla
Requires: autokey-common = %{version}-%{release}
%{?_qt4_version:Requires: qt4 >= %{_qt4_version}}
Provides: autokey = %{version}-%{release}
%description qt
This package contains the QT front end for autokey

%prep
%setup -q


%build
%{__python} setup.py build

%install
rm -rf %{buildroot}
%{__python} setup.py install -O1 --skip-build --root %{buildroot}

#QT desktop
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name1}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey QT
Comment=Desktop automation utility
Exec=autokey-qt
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=Qt;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

#GTK desktop
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name2}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey GTK
Comment=Desktop automation utility
Exec=autokey-gtk
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=GTK;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

desktop-file-validate %{buildroot}/%{_datadir}/applications/autokey-qt.desktop

# remove shebang from python libraries
for lib in $(find %{buildroot}%{python_sitelib}/autokey/ -name "*.py"); do
 sed '/\/usr\/bin\/env/d' $lib > $lib.new &&
 touch -r $lib $lib.new &&
 mv $lib.new $lib
done

%post gtk
update-desktop-database > /dev/null 2>&1 || :

%post qt
update-desktop-database > /dev/null 2>&1 || :

%postun gtk
update-desktop-database > /dev/null 2>&1 || :

%postun qt
update-desktop-database > /dev/null 2>&1 || :

%files

%files common
%doc doc/scripting ACKNOWLEDGMENTS COPYING
# For noarch packages: sitelib
%{python_sitelib}/autokey/common.*
%{python_sitelib}/autokey/configmanager.*
%{python_sitelib}/autokey/daemon.*
%{python_sitelib}/autokey/evdev.*
%{python_sitelib}/autokey/__init__.*
%{python_sitelib}/autokey/interface.*
%{python_sitelib}/autokey/iomediator.*
%{python_sitelib}/autokey/model.*
%{python_sitelib}/autokey/nogui.*
%{python_sitelib}/autokey/scripting.*
%{python_sitelib}/autokey/service.*
%{python_sitelib}/autokey-*.egg-info
%{_datadir}/pixmaps/*

%files gtk
%{python_sitelib}/autokey/gtkui/*
%{python_sitelib}/autokey/gtkapp.*
%{_bindir}/autokey-gtk
%{_datadir}/applications/autokey-gtk.desktop
%{_mandir}/man1/autokey-gtk.1.bz2
%{_datadir}/applications/%{name2}.desktop

%files qt
%{python_sitelib}/autokey/qtui/*
%{python_sitelib}/autokey/qtapp.*
%{_bindir}/autokey-qt
%{_datadir}/applications/autokey-qt.desktop
%{_mandir}/man1/autokey-qt.1.bz2
%{_datadir}/applications/%{name1}.desktop


%changelog

I'm not sure what the desktop file names are so I filled them in with: qt and gtk
« Last Edit: November 04, 2011, 05:22:57 PM by glamdring »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Need help with Desktop Entry
« Reply #5 on: November 04, 2011, 05:29:36 PM »
No need to get fancy. Simply add the extra bits to the desktop entry part of the spec.

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: Need help with Desktop Entry
« Reply #6 on: November 05, 2011, 04:29:43 AM »
I tried that, Neal but every time I build --all I just get one desktop entry ... and I can't figure out what I was doing wrong so I thought I'd just remove one of the other desktop entry.

By the way, AutoKey is dropping QT and the newer version will only have GTK.

Thanks, glamdring. I will try your suggestion, and cross my fingers that the built packages will be able to crate the proper, respective desktop entries.
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Need help with Desktop Entry
« Reply #7 on: November 05, 2011, 05:28:22 AM »
Archie,     
Have a look at a package that does create 2 separate .desktop files. Synaptic, for example, does this.     

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: Need help with Desktop Entry
« Reply #8 on: November 05, 2011, 10:21:17 AM »
Archie,     
Have a look at a package that does create 2 separate .desktop files. Synaptic, for example, does this.     

I can think of one ... recordMyDesktop ... and if you have any other example, please.
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Need help with Desktop Entry
« Reply #9 on: November 05, 2011, 12:11:50 PM »
Can't think of another at the moment. Sorry.     

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: Need help with Desktop Entry
« Reply #10 on: November 05, 2011, 12:49:49 PM »
I looked over the code I posted, you already have the .desktop in files so this should work:

Code: [Select]
# sitelib for noarch packages
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

%define name1 autokey-qt
%define name2 autokey-gtk

Name: autokey
Version: 0.71.3
Release: 4
Summary: Desktop automation utility
Group: Accessibility
License: GPLv3
URL: http://autokey.googlecode.com
Source0: http://autokey.googlecode.com/files/%{name}_%{version}.tar.gz
BuildArch: x86_64
BuildRequires: python-xlib
BuildRequires: python-notify
BuildRequires: pygtk2
BuildRequires: pygtk2-libglade
BuildRequires: desktop-file-utils
Requires: autokey-common
Requires: autokey-gtk
Provides: autokey = %{version}-%{release}

%description
AutoKey is a desktop automation utility for Linux and X11. It allows
the automation of virtually any task by responding to typed abbreviations
and hot keys. It offers a full-featured GUI that makes it highly
accessible for novices, as well as a scripting interface offering
the full flexibility and power of the Python language.

%package common
Summary: Desktop automation utility - common data
Group: Accessibility
Requires: python >= 2.6
Provides: autokey = %{version}-%{release}

%description common
This package contains the common data shared between the various front ends.

%package gtk
Summary: AutoKey GTK+ version
Group: Accessibility
Requires: pygtksourceview
Requires: autokey-common = %{version}-%{release}
Provides: autokey = %{version}-%{release}
%description gtk
This package contains the GTK+ front end for autokey

%package qt
Summary: AutoKey QT version
Group: Accessibility
Requires: python-qt4-qscintilla%{_datadir}/applications/autokey-qt.desktop
Requires: autokey-common = %{version}-%{release}
%{?_qt4_version:Requires: qt4 >= %{_qt4_version}}
Provides: autokey = %{version}-%{release}
%description qt
This package contains the QT front end for autokey

%prep
%setup -q


%build
%{__python} setup.py build

%install
rm -rf %{buildroot}
%{__python} setup.py install -O1 --skip-build --root %{buildroot}

#QT desktop
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name1}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey QT
Comment=Desktop automation utility
Exec=autokey-qt
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=Qt;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

#GTK desktop
mkdir -p %{buildroot}%{_datadir}/applications
%__cat > %{buildroot}%{_datadir}/applications/%{name2}.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Name=AutoKey GTK
Comment=Desktop automation utility
Exec=autokey-gtk
Icon=akicon.png
Terminal=false
Type=Application
StartupNotify=true
Categories=GTK;Utility;More Applications/Monitoring;X-MandrivaLinux-More Applications/Monitoring;
EOF

desktop-file-validate %{buildroot}/%{_datadir}/applications/autokey-qt.desktop

# remove shebang from python libraries
for lib in $(find %{buildroot}%{python_sitelib}/autokey/ -name "*.py"); do
 sed '/\/usr\/bin\/env/d' $lib > $lib.new &&
 touch -r $lib $lib.new &&
 mv $lib.new $lib
done

%post gtk
update-desktop-database > /dev/null 2>&1 || :

%post qt
update-desktop-database > /dev/null 2>&1 || :

%postun gtk
update-desktop-database > /dev/null 2>&1 || :

%postun qt
update-desktop-database > /dev/null 2>&1 || :

%files

%files common
%doc doc/scripting ACKNOWLEDGMENTS COPYING
# For noarch packages: sitelib
%{python_sitelib}/autokey/common.*
%{python_sitelib}/autokey/configmanager.*
%{python_sitelib}/autokey/daemon.*
%{python_sitelib}/autokey/evdev.*
%{python_sitelib}/autokey/__init__.*
%{python_sitelib}/autokey/interface.*
%{python_sitelib}/autokey/iomediator.*
%{python_sitelib}/autokey/model.*
%{python_sitelib}/autokey/nogui.*
%{python_sitelib}/autokey/scripting.*
%{python_sitelib}/autokey/service.*
%{python_sitelib}/autokey-*.egg-info
%{_datadir}/pixmaps/*

%files gtk
%{python_sitelib}/autokey/gtkui/*
%{python_sitelib}/autokey/gtkapp.*
%{_bindir}/autokey-gtk
%{_mandir}/man1/autokey-gtk.1.bz2
%{_datadir}/applications/%{name2}.desktop

%files qt
%{python_sitelib}/autokey/qtui/*
%{python_sitelib}/autokey/qtapp.*
%{_bindir}/autokey-qt
%{_mandir}/man1/autokey-qt.1.bz2
%{_datadir}/applications/%{name1}.desktop


%changelog

Although you said manually entering them wasn't working, in which case my solution probably won't either.
Out of curiosity what is the difference from:
Code: [Select]
cat > %{buildroot}%{_datadir}/applications/%{name2}.desktop << EOF
And what you use:
Code: [Select]
%__cat > %{buildroot}%{_datadir}/applications/%{name2}.desktop << EOF
« Last Edit: November 05, 2011, 12:51:47 PM by glamdring »

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: Need help with Desktop Entry
« Reply #11 on: November 05, 2011, 10:45:30 PM »
Code: [Select]
%{__cat} <<EOF >$RPM_BUILD_ROOT%{_menudir}/%{name}
was what I followed outlined in the guide. As for the difference between the two, I'm not sure what yet. Will update results as soon as I have them.

Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12525
Re: Need help with Desktop Entry
« Reply #12 on: November 05, 2011, 11:21:32 PM »
Code: [Select]
%{__cat} <<EOF >$RPM_BUILD_ROOT%{_menudir}/%{name}
was what I followed outlined in the guide. As for the difference between the two, I'm not sure what yet. Will update results as soon as I have them.



%{_menudir}/%{name} is depreciated and should be removed from your specfiles.


Thanks to everyone who donates. You keep the servers running.

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: Need help with Desktop Entry
« Reply #13 on: November 06, 2011, 12:28:38 AM »
Of course. I meant it as the reference to /usr/share/applications/autokey-qt.desktop
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42