Pages

Showing posts with label fix. Show all posts
Showing posts with label fix. Show all posts

2015-09-18

Mimetype problems

Environment: Slackware 14.1 + Openbox + spacefm 1.0.3

Problems: 

Wrong (already deleted etc) apps in filetype open with list + wrong epub icon.
1. Newer version of Spacefm looks for .desktop files in ~/.local/share/applications and rearranges things in mimeinfo.cache. Result - apps list for given file-type gets strange and occasionally irrelevant.
(How and what to do with mimetypes in Spacefm.)
2. xml file in /usr/share/mime shows one icon listed, filemanager shows something complitely unrelated. Why, is unknown to me.

Solutions:
1. All mime defaults should go to
- either .local/share/applications/mimeapps.list,
- or to .config/mimeapps.list.
Entries look like this, for example:
[Default Applications]
application/vnd.oasis.opendocument.text=libreoffice-writer.desktop;
application/pdf=qpdfview.desktop;


Moral: As long as something is not rewriting your .local/share/applications/mimeinfo.cache too frequenty - you can change things there. It's easier and more flexible, you can also tune what app appears in second, third or whatever place on the list.
BUT, mimeinfo.cache IS prone to be rewritten, so let's change the .list with Spacefm:
rightclick on file - open - choose app for default - rightclick on it - make it default.
The same way you can remove or add apps to or from your available handlers list.
And the same for all filetypes what are not yet defined (fun and giggles for 0.5-1 hour).

2. Changing mimetype icons can also be done manually or with Spacefm:
a) copy yourproblematic.xml from /usr/share/mime/applications to ./local/share/mime/applications/packages
There is a line with <general-icon name=.../> in it. Change it from general-icon to icon, and replace icon name with your favourite icon in  ~/.icons/yourtheme/mimetype/ folder.
Run update-mime-database ~/.local/share/mime
b) A bit easire way, with Spacefm - rightclick on file - open - rightclick on default app - pick line with ...xxx.xml - click. Spacefm copies xml file from /usr/share/mime to your .local/share/mime/packages and opens it in editor.
Edit it the same way as in a).
Done.

2014-08-10

Icon cache refresh

Sometimes I play with icons - change them or create new ones. And most excitedly, the folder they are in gets broken/unknown icon pics into it after that.
That means - icon-cache needs to be refreshed. Many distros have a script for that which runs on startup. Or something similar - on one way or another, depends on distro and desktop environment.
But if not, one needs to update cache manually.
Basic and primitive way to do this is gtk-update-icon-cache command. That same app is used also by a lot of nice frontends. The command, in terminal, looks like that, in foolproof way:
gtk-update-icon-cache -f -t /path to your icondir - dir where index.theme is
'-f' means force overwrite old cache despite of it state, '-t' means don't worry if there is no index.theme  file.
Dandy. Yeah, but quite frequently not so - and what you get is:
gtk-update-icon-cache: The generated cache was invalid.
You also see that miscreated file starts with '.' - and it's useless as cache.
I happened to have exactly that sad outcome when trying to refresh my icon-theme cache. After exceptionally frustrating googling, I found that - in my case:
- Only thing that mattered (of multiple web-hints), was spaces in icon names. Not existence of icon-size folders, or of index.theme... or something else...
That means, of course, only that I didn't have other possible problems ... if there are more.

Anyway, I got my very big collected icon-theme validated after I removed all spaces from filenames, and nothing else (well, I also checked if my index.theme was correct. It was).

The script below (Thanks to Michael, stackoverflow) looks also to subdirs so, in idea you can run it from /icons or ~/.icons and get every spacy filename switched.
I did it in slow way - as I wanted to know where problems were. I created test-folder and copy/pasted iconfolders to there one by one, and tried to make cache again. Of course, it's easier to change the script to have 'echo' to show which files were changed... in case you are fluent in bash. I'm not, I am outright moron in it. So I did it mechanically, and found that 3 of 12 folders had 'space-problems'.
And here is the script that fixed it:

#! /bin/sh
# Script what finds spaces in filenames and replaces them with _
# to get gtk-update-icon-cache to validate.

# Change this folder according to needs
cd /home/homeros/.icons/test/mimetypes

find . -depth -name '* *' \
| while IFS= read -r f ; \
do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; \
done
That was that.