marianosimone / epub-thumbnailer

Script to extract the cover of an epub book and create a thumbnail for it
GNU General Public License v3.0
191 stars 29 forks source link

Wrong way to determine Gnome version #5

Closed tigran123 closed 9 years ago

tigran123 commented 9 years ago

You do os.popen('apt-cache show gnome-shell | grep Version') and this fails because my system has no such command apt-cache (it is only for Debian-based systems like ubuntu and I use Fedora Core Linux).

The proper way to determine the version of gnome is to run gnome-shell --version. Anyway, I'll hardcode your check_gnome_version() function to return gnome3 and see if the result works. If it does, then your script is exactly what I was about to write (as I need it for the system I am developing) and so you may have saved me a lot of time --- thank you! :)

tigran123 commented 9 years ago

It works wonderfully --- only I had to edit the file /usr/bin/epub-thumbnailer to change PNG to JPEG in the call to im.save() because I need JPEG format images for my purpose, not PNG. Thank you again for this nice little utility! Do you have a similar one for MOBI format as well? I need it too... (btw, yesterday I wrote a cover extractor for fb2, including an XML metadata parser using libexpat).

marianosimone commented 9 years ago

@tigran123 you are welcome! I'll test gnome-shell --version in a couple of different setups and will update accordingly, thanks for the suggestion!

As per MOBI, I don't know any alternative (nor I know much about MOBI's internal structure), sorry

marianosimone commented 9 years ago

@tigran123 I checked and it seems like using either option is not the best solution

I'm now running Linux Mint, and using MATE instead of gnome-shell, and it works because apt-cache searches the repos for gnome-shell, and version 3 is the one available. As the MATE version I'm using is compatible with that regarding thumbnailers, I failed to realize that it was the wrong approach.

The right way should be to check first for the Desktop Environment, and then finally for the version to see which kind of installation to do (i.e. the Gnome 2 way, or the Gnome 3)

Could you tell me what:

ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"

Returns for you? I don't have access to a Fedora box now.

Thanks!

tigran123 commented 9 years ago

Ok, sure, here is the output:

$ ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
   28 ?        00:00:00 kdevtmpfs
  838 ?        00:00:00 gnome-session
 1011 ?        00:00:00 gnome-keyring-d
 1018 ?        00:00:00 gnome-settings-
 1103 ?        00:00:05 gnome-shell
 1183 ?        00:00:00 gnome-shell-cal
 1292 ?        00:00:00 gnome-terminal
 1296 ?        00:00:00 gnome-pty-helpe
marianosimone commented 9 years ago

@tigran123 thanks a lot!

After some testing in other boxes, I think I've come up with a solution. If it's not too much to ask, could you download this: https://gist.github.com/marianosimone/07ddfb666e9ddd765612 and run it to see what it says? (expecting gnome3)

Thanks!

tigran123 commented 9 years ago

It returns gnome3 on my system.

marianosimone commented 9 years ago

Thanks @tigran123, issue solved. I still need more testing on gnome2 systems and alternative Desktop Environments, but for now it seems that gnome-shell and MATE are covered

tigran123 commented 9 years ago

Btw, I found an utility that does extract cover from mobi files (and epubs too) --- it is called ebook-meta and is part of calibre. However, I can't get it to run from within Apache webserver yet (when run as a normal user it works fine and extracts the cover and shows complete metadata etc).