nicklan / pnmixer

Volume mixer for the system tray
GNU General Public License v3.0
152 stars 32 forks source link

uses files from current working directory #178

Closed setharnold closed 6 years ago

setharnold commented 6 years ago

Hello, while trying to track down a problem I used strace on pnmixer and was surprised that it was looking for files in the data directory of the current working directory:

$ grep '"\.' /tmp/pnmixer  | grep ENOENT
access("./data/ui/popup-menu-gtk3.glade", F_OK) = -1 ENOENT (No such file or directory)
access("./data/ui/popup-window-vertical-gtk3.glade", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-muted.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-off.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-low.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-medium.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-high.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-muted.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-off.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-low.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-medium.png", F_OK) = -1 ENOENT (No such file or directory)
access("./data/pixmaps/pnmixer-high.png", F_OK) = -1 ENOENT (No such file or directory)

Thanks

elboulangero commented 6 years ago

Yep that's used when you run pnmixer in-tree, during development. That's probably not a good practice though. What do you suggest for improvement :) ?

setharnold commented 6 years ago

Perhaps something along the lines of (untested)

#ifdef DEV
#define PREFIX "data"
#else
#define PREFIX "/usr/share/pnmixer/"
#endif

and then you can use PREFIX "pixmaps/pnimxer-high.png" in the sources and let the CPP string concatenation give you different paths depending if -DDEV were passed on the compiler's command line.

Thanks

hasufell commented 6 years ago

That should be done idiomaticially via cmake. I'm not yet sure exactly how, because we must avoid that developers/contributors accidentally use wrong data files. It could be done via CMAKE_BUILD_TYPE, but if you forget to set it, you get mixed results.

hasufell commented 6 years ago

Check https://github.com/nicklan/pnmixer/pull/181