Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't hardcode /usr paths #310
  • Loading branch information
fossfreedom committed May 9, 2020
1 parent 5a5dd51 commit 808dff8
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion budgie-brightness-controller/src/Applet.vala
Expand Up @@ -111,7 +111,7 @@ public class Applet : Budgie.Applet
"[Desktop Entry]",
"Type=Application",
"Name=GNOME Settings Daemon's color plugin",
"Exec=/usr/lib/gnome-settings-daemon/gsd-color",
"Exec=" + Config.PACKAGE_LIBDIR + "/gnome-settings-daemon/gsd-color",
"OnlyShowIn=GNOME;",
"NoDisplay=false",
"X-GNOME-Autostart-Phase=Initialization",
Expand Down
4 changes: 2 additions & 2 deletions budgie-brightness-controller/src/helpers/DimHelper.vala
Expand Up @@ -67,7 +67,7 @@ public class DimHelper
}

// Load Dims From Device
var dimsString = subprocessHelper.RunAndGetResult({"/usr/bin/xrandr", "-q"});
var dimsString = subprocessHelper.RunAndGetResult({Config.PACKAGE_BINDIR + "/xrandr", "-q"});

dimsString = dimsString._strip();
if (dimsString == "")
Expand Down Expand Up @@ -133,7 +133,7 @@ public class DimHelper
//print(@"DimHelper.SetBrightness: $name $brightness \n");
var aOnePercentOfbrightness = brightness / 100;
var aOnePercentOfBlue = blue / 100;
subprocessHelper.Run({"/usr/bin/xrandr", "--output", @"$name", "--gamma", @"1:1:$aOnePercentOfBlue", "--brightness", @"$aOnePercentOfbrightness"});
subprocessHelper.Run({Config.PACKAGE_BINDIR + "/xrandr", "--output", @"$name", "--gamma", @"1:1:$aOnePercentOfBlue", "--brightness", @"$aOnePercentOfbrightness"});
Save();
}

Expand Down
10 changes: 5 additions & 5 deletions budgie-brightness-controller/src/helpers/LightHelper.vala
Expand Up @@ -67,7 +67,7 @@ public class LightHelper
}

// Load Lights Frome Device
var lightsString = subprocessHelper.RunAndGetResult({"/usr/bin/ls", "/sys/class/backlight"});
var lightsString = subprocessHelper.RunAndGetResult({Config.PACKAGE_BINDIR + "/ls", "/sys/class/backlight"});

lightsString = lightsString._strip();
if (lightsString == "")
Expand Down Expand Up @@ -131,24 +131,24 @@ public class LightHelper

private double GetMaxBrightness(string name)
{
return subprocessHelper.RunAndGetResult({"/usr/bin/cat", @"/sys/class/backlight/$name/max_brightness"}).to_double();
return subprocessHelper.RunAndGetResult({Config.PACKAGE_BINDIR + "/cat", @"/sys/class/backlight/$name/max_brightness"}).to_double();
}

public double GetBrightness(string name)
{
return subprocessHelper.RunAndGetResult({"/usr/bin/cat", @"/sys/class/backlight/$name/brightness"}).to_double();
return subprocessHelper.RunAndGetResult({Config.PACKAGE_BINDIR + "/cat", @"/sys/class/backlight/$name/brightness"}).to_double();
}

public void SetBrightness(string name, double brightness)
{
var brightnessInt = (int)brightness;
if(haveGnomeSettingsDaemon332)
{
subprocessHelper.Run({"/usr/bin/pkexec", "/usr/lib/gnome-settings-daemon/gsd-backlight-helper", @"/sys/class/backlight/$name", @"$brightnessInt"});
subprocessHelper.Run({Config.PACKAGE_BINDIR + "/pkexec", Config.PACKAGE_LIBDIR + "/gnome-settings-daemon/gsd-backlight-helper", @"/sys/class/backlight/$name", @"$brightnessInt"});
}
else if(haveGnomeSettingsDaemonOlderThan332)
{
subprocessHelper.Run({"/usr/bin/pkexec", "/usr/lib/gnome-settings-daemon/gsd-backlight-helper", "--set-brightness", @"$brightnessInt"});
subprocessHelper.Run({Config.PACKAGE_BINDIR + "/pkexec", Config.PACKAGE_LIBDIR + "/gnome-settings-daemon/gsd-backlight-helper", "--set-brightness", @"$brightnessInt"});
}

Save();
Expand Down
4 changes: 2 additions & 2 deletions budgie-brightness-controller/src/widgets/Popover.vala
Expand Up @@ -206,13 +206,13 @@ public class Popover : Budgie.Popover
if(lightHelper.haveGnomeSettingsDaemon332)
{
yield subprocessLauncher.spawnv(
{"/usr/bin/cat", @"/sys/class/backlight/$name/brightness"}
{Config.PACKAGE_BINDIR + "/cat", @"/sys/class/backlight/$name/brightness"}
).communicate_utf8_async(null, null, out output, null);
}
else if(lightHelper.haveGnomeSettingsDaemonOlderThan332)
{
yield subprocessLauncher.spawnv(
{"/usr/bin/pkexec", "/usr/lib/gnome-settings-daemon/gsd-backlight-helper", "--get-brightness"}
{Config.PACKAGE_BINDIR + "/pkexec", Config.PACKAGE_LIBDIR + "/gnome-settings-daemon/gsd-backlight-helper", "--get-brightness"}
).communicate_utf8_async(null, null, out output, null);
}

Expand Down
8 changes: 4 additions & 4 deletions budgie-hotcorners/src/HotCornersApplet.vala
Expand Up @@ -28,7 +28,7 @@ namespace HCSupport {
*/

private bool locked () {
string cmd = "/usr/bin/pgrep -f gnome-screensaver-dialog";
string cmd = Config.PACKAGE_BINDIR + "/pgrep -f gnome-screensaver-dialog";
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand All @@ -45,7 +45,7 @@ namespace HCSupport {

private bool check_onapplet(string path, string applet_name) {
/* check if the applet still runs */
string cmd = "/usr/bin/dconf dump " + path;
string cmd = Config.PACKAGE_BINDIR + "/dconf dump " + path;
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down Expand Up @@ -298,7 +298,7 @@ namespace HotCornersApplet {
}

private void sendwarning (string msg_header, string message) {
string set_icon = "/usr/bin/notify-send -i budgie-hotcorners-symbolic ";
string set_icon = Config.PACKAGE_BINDIR + "/notify-send -i budgie-hotcorners-symbolic ";
string header = "'" + msg_header + "'";
// WindowPreviews is the name of a Budgie Applet and does not need to be translated
string body = " '" + message + "'";
Expand Down Expand Up @@ -429,7 +429,7 @@ namespace HotCornersApplet {
}

private bool procruns (string processname) {
string cmd = @"/usr/bin/pgrep -f $processname";
string cmd = Config.PACKAGE_BINDIR + "/pgrep -f $processname";
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
2 changes: 1 addition & 1 deletion budgie-recentlyused/src/budgie-recentlyused.vala
Expand Up @@ -184,7 +184,7 @@ namespace RecentlyUsedApplet {
string menuname = getmenuname(longname);
Gtk.MenuItem newitem = new Gtk.MenuItem.with_label(menuname);
// command
string command = "/usr/bin/xdg-open " + "'" + longname.replace(
string command = Config.PACKAGE_BINDIR + "/xdg-open " + "'" + longname.replace(
"'", "'\\''"
) + "'";;
// tooltip
Expand Down
4 changes: 2 additions & 2 deletions budgie-showtime/src/showtime_desktop/showtime_desktop.vala
Expand Up @@ -348,7 +348,7 @@ namespace ShowTime {
string[] monthdayvars = {
"%e", "%-e", "%_e", "%d", "%-d", "%_d"
};
string cmd = "/usr/bin/locale date_fmt";
string cmd = Config.PACKAGE_BINDIR + "/locale date_fmt";
string output = "";
try {
StringBuilder builder = new StringBuilder ();
Expand Down Expand Up @@ -411,7 +411,7 @@ namespace ShowTime {

private bool check_onapplet () {
// check if the applet still runs
string cmd = "/usr/bin/dconf dump /com/solus-project/budgie-panel/applets/";
string cmd = Config.PACKAGE_BINDIR + "/dconf dump /com/solus-project/budgie-panel/applets/";
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
Expand Up @@ -206,7 +206,7 @@ namespace WallStreetControls {
}

private bool processruns (string application) {
string cmd = "/usr/bin/pgrep -f " + application;
string cmd = Config.PACKAGE_BINDIR + "/pgrep -f " + application;
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
6 changes: 3 additions & 3 deletions budgie-weathershow/src/weathershow/WeatherShow.vala
Expand Up @@ -77,7 +77,7 @@ namespace WeatherShowFunctions {
}

private bool check_onwindow(string path) {
string cmd_check = "/usr/bin/pgrep -f " + path;
string cmd_check = Config.PACKAGE_BINDIR + "/pgrep -f " + path;
string output;
try {
GLib.Process.spawn_command_line_sync(cmd_check, out output);
Expand All @@ -97,7 +97,7 @@ namespace WeatherShowFunctions {
if (win_exists) {
try {
Process.spawn_command_line_async(
"/usr/bin/pkill -f ".concat(path));
Config.PACKAGE_BINDIR + "/pkill -f ".concat(path));
}
catch (SpawnError e) {
/* nothing to be done */
Expand Down Expand Up @@ -1392,7 +1392,7 @@ namespace WeatherShowApplet {

private bool check_onapplet(string path, string applet_name) {
// check if the applet still runs
string cmd = "/usr/bin/dconf dump " + path;
string cmd = Config.PACKAGE_BINDIR + "/dconf dump " + path;
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
2 changes: 1 addition & 1 deletion budgie-window-shuffler/src/jump.vala
Expand Up @@ -47,7 +47,7 @@ namespace JumpActive {
}

private bool procruns (string processname) {
string cmd = @"/usr/bin/pgrep -f $processname";
string cmd = Config.PACKAGE_BINDIR + "/pgrep -f $processname";
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
2 changes: 1 addition & 1 deletion budgie-window-shuffler/src/shuffler_control.vala
Expand Up @@ -591,7 +591,7 @@ namespace ShufflerControls {
}

private bool procruns (string processname) {
string cmd = @"/usr/bin/pgrep -f $processname";
string cmd = Config.PACKAGE_BINDIR + "/pgrep -f $processname";
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
2 changes: 1 addition & 1 deletion budgie-window-shuffler/src/windowshufflerdaemon.vala
Expand Up @@ -332,7 +332,7 @@ namespace ShufflerEssentialInfo {
*/
int yshift = 0;
string winsubj = @"$w_id";
string cmd = "/usr/bin/xprop -id ".concat(winsubj, " _NET_FRAME_EXTENTS");
string cmd = Config.PACKAGE_BINDIR + "/xprop -id ".concat(winsubj, " _NET_FRAME_EXTENTS");
string output = "";
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
2 changes: 1 addition & 1 deletion budgie-wpreviews/src/previews_controls.vala
Expand Up @@ -120,7 +120,7 @@ namespace PreviewsControls {
}

private bool procruns (string processname) {
string cmd = @"/usr/bin/pgrep -f $processname";
string cmd = Config.PACKAGE_BINDIR + "/pgrep -f $processname";
string output;
try {
GLib.Process.spawn_command_line_sync(cmd, out output);
Expand Down
2 changes: 1 addition & 1 deletion budgie-wpreviews/src/previews_creator.vala
Expand Up @@ -299,7 +299,7 @@ namespace create_previews {

private bool get_idle () {
// see if idle exceeds 90 seconds
string cmd = "/usr/bin/xprintidle";
string cmd = Config.PACKAGE_BINDIR + "/xprintidle";
string output;
int curridle = 0;
try {
Expand Down
4 changes: 2 additions & 2 deletions budgie-wpreviews/src/previews_daemon.vala
Expand Up @@ -108,7 +108,7 @@ namespace NewPreviews {
string output = "";
try {
GLib.Process.spawn_command_line_sync(
"/usr/bin/xinput --list", out output
Config.PACKAGE_BINDIR + "/xinput --list", out output
);
}
catch (Error e) {
Expand Down Expand Up @@ -331,7 +331,7 @@ namespace NewPreviews {
string output = "";
try {
GLib.Process.spawn_command_line_sync(
"/usr/bin/xinput --query-state " + s, out output
Config.PACKAGE_BINDIR + "/xinput --query-state " + s, out output
);
}
catch (Error e) {
Expand Down
3 changes: 3 additions & 0 deletions meson.build
Expand Up @@ -26,6 +26,7 @@ intltool = find_program('intltool-merge')
prefix = get_option('prefix')
libdir = join_paths(prefix, get_option('libdir'))
datadir = join_paths(prefix, get_option('datadir'))
bindir = get_option('bindir')
sysconfdir = get_option('sysconfdir')

add_project_arguments(
Expand All @@ -48,6 +49,8 @@ conf = configuration_data()
conf.set('PACKAGE_NAME', 'budgie-extras')
conf.set_quoted('PACKAGE_LOCALEDIR', LOCALE_DIR)
conf.set_quoted('PACKAGE_LIBDIR', libdir)
conf.set_quoted('PACKAGE_BINDIR', bindir)
conf.set_quoted('PACKAGE_SHAREDIR', datadir)

config_h = configure_file(
output: 'config.h',
Expand Down
2 changes: 2 additions & 0 deletions vapi/config.vapi
Expand Up @@ -3,4 +3,6 @@ namespace Config {
public const string GETTEXT_PACKAGE;
public const string PACKAGE_LOCALEDIR;
public const string PACKAGE_LIBDIR;
public const string PACKAGE_BINDIR;
public const string PACKAGE_SHAREDIR;
}

0 comments on commit 808dff8

Please sign in to comment.