File ayat-mime-type.spec of Package islamic-ayat-mime-type

Name:		ayat-mime-type
Version:	1.0
Release:	1
Summary:	Create mime type for .ayt extension.
License:	GPL3
Group:		utils
Requires(pre):	shared-mime-info
Requires:	sa.edu.ksa.ayat
BuildArch:	noarch

%description

%prep

%install
# Create mime type file
mkdir -p %{buildroot}%{_datadir}/mime/packages
echo '<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/ayat">
      <sub-class-of type="application/zip"/>
        <comment>Ayat archive</comment>
        <icon name="sa.edu.ksa.ayat"/>
        <glob pattern="*.ayt"/>
    </mime-type>
</mime-info>
' >> %{buildroot}%{_datadir}/mime/packages/application-ayat.xml

%clean

%post
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

# Create new ayat shortcut with new mime & add to islamic menus
rm -rf /opt/Ayat/share/META-INF/AIR/sa.edu.ksa.ayat.desktop /usr/share/applnk/sa.edu.ksa.ayat.desktop
echo '[Desktop Entry]
Name=Ayat
Name[ar]=آيات
GenericName=Electronic simulation of the Holy Quran
GenericName[ar]=محاكاة الكترونية للمصحف الشريف
Comment=<>
Exec=/opt/Ayat/bin/Ayat  %u
Type=Application
Terminal=false
Icon=sa.edu.ksa.ayat
StartupNotify=true
X-KDE-StartupNotify=true
X-AppInstall-Package=sa.edu.ksa.ayat
X-AppInstall-Section=main
MimeType=application/ayat;
Categories=X-Islamic-Software;GTK;
' >>  /opt/Ayat/share/META-INF/AIR/sa.edu.ksa.ayat.desktop

# add ayat to kde ServiceMenus
mkdir -p /usr/share/kde4/services/ServiceMenus
echo '[Desktop Entry]
Actions=add_ayat_data;
Encoding=UTF-8
Icon=server-database
MimeType=
ServiceTypes=
Type=Service
Version=1.1
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,inode/directory
X-KDE-Submenu=Islamic Data

[Desktop Action add_ayat_data]
Exec=mv ~/.appdata/sa.edu.ksa.ayat/"Local Store" ~/sa.edu.ksa.ayat-backup; mkdir -p ~/.appdata/sa.edu.ksa.ayat; ln -s "%u" ~/.appdata/sa.edu.ksa.ayat/"Local Store" | kdialog --icon=sa.edu.ksa.ayat --title="%u" --passivepopup="Add Local Data To Ayat Finish...."
Icon=sa.edu.ksa.ayat
Name=Add Local Data to Ayat
' >>  /usr/share/kde4/services/ServiceMenus/Ayat1.desktop

echo '[Desktop Entry]
Actions=extract_data;
Encoding=UTF-8
Icon=sa.edu.ksa.ayat
MimeType=
ServiceTypes=
Type=Service
Version=1.1
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,,application/ayat
# X-KDE-Submenu=
X-KDE-Priority=TopLevel

[Desktop Action extract_data]
Exec=mkdir -p ~/.appdata/sa.edu.ksa.ayat/"Local Store"; ark --b -a -o ~/.appdata/sa.edu.ksa.ayat/"Local Store" %U | zenity --progress --title "Extracting" --text "Extracting to Ayat Local Data \nPlease Wait ......." --pulsate
Icon=sa.edu.ksa.ayat
Name=Extract to Ayat Local Data
' >>  /usr/share/kde4/services/ServiceMenus/Ayat2.desktop

%postun
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
rm -rf /usr/share/kde4/services/ServiceMenus/Ayat*.desktop
update-desktop-database

%files
%defattr(-,root,root)
%{_datadir}/mime/packages/application-ayat.xml

%changelog
* Wed Jan 04 2012 Muhammad Shaban <Mr.Muhammad@linuxac.org> 1.0-1
- Initial Release