You are not logged in.

#1 2016-03-06 15:29:00

tamat
New Member
Registered: 2016-03-06
Posts: 3

Obmenu pipemenu of desktop files

Hey there! I want create script, to generate pipemenu, with apps in desktop user dir. Here is bash script, but i have problem with locate icons if .desktop file not contain full icon path (example Icon=steam_icon_400). Any ideas?

-----Mod Move from Scripts,Tuts&Tips: this isn't a working solution yet wink ----------

Last edited by damo (2016-03-06 16:42:59)

Offline

#2 2016-03-06 16:47:38

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Obmenu pipemenu of desktop files

First thought is to use the path to the default locations using....

According to Icon Theme Specification, "apps
should look [for icons] in $HOME/.icons (for backwards compatibility),
in $XDG_DATA_DIRS/icons and in /usr/share/pixmaps (in that order)."

So I would have a function that looks in each location in turn until it finds the icon, then passes that path back.

Last edited by damo (2016-03-07 12:16:48)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#3 2016-03-07 04:25:53

tamat
New Member
Registered: 2016-03-06
Posts: 3

Re: Obmenu pipemenu of desktop files

In my system var $XDG_DATA_DIRS is empty. I choose the following search paths, but "find" works slow (3-4 seconds for 5 icons) too.

find $HOME/.icons $HOME/.local/share/icons /usr/share/icons /usr/share/pixmaps -type f -iname $ICON.* | tail -1

Offline

#4 2016-03-07 07:33:16

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Obmenu pipemenu of desktop files

tamat wrote:

"find" works slow

Use locate(1) instead.

If you do, remember to use updatedb(1) after adding any new icons.


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#5 2016-03-07 07:44:07

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,436
Website

Re: Obmenu pipemenu of desktop files

Why not just edit desktop files to use absolute path to icon? (irc relative paths should not be used anyway, it is either icon-name or full-path.)
Some reading https://wiki.archlinux.org/index.php/De … le_example

Last edited by brontosaurusrex (2016-03-07 08:01:41)

Offline

#6 2016-03-07 10:33:30

tamat
New Member
Registered: 2016-03-06
Posts: 3

Re: Obmenu pipemenu of desktop files

brontosaurusrex wrote:

irc relative paths should not be used anyway, it is either icon-name or full-path.

That is no relative path, some apps (steam, arduino IDE) use icon-name only, but in obmenu can use only full path. Need a fast method to resolve full path by icon name.

Offline

#7 2016-03-07 11:19:13

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Obmenu pipemenu of desktop files

Here is a possible approach. Use a `find` or `locate` function to get the icon location, write the path to a file, and exit the function as soon as it is found (so the search doesn't keep going).

So your script looks for a match for the desktop file and its icon in the datafile: if it exists, then use it, else the .desktop file is new, so do the search and add it to the file.

This way the search only happens the first time and the pipemenu isn't slowed down unless you have just installed a new application.


EDIT: I notice your script has `grep | head | sed | sed`: that looks like a very inefficient way of extracting the text you want. Maybe a single awk or sed command, with bash parameter substitution, would be quicker?

BTW, what is the purpose of this script? There may be easier ways of achieving what you want to do

Last edited by damo (2016-03-07 12:17:32)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

Board footer

Powered by FluxBB