From c537b4cc6d0bf2cedcb95848328e902c5be50ace Mon Sep 17 00:00:00 2001 From: David Date: Sat, 10 May 2014 13:31:43 +1200 Subject: Better makefile (I got sidetracked) --- trayfreq_set_interface.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 trayfreq_set_interface.c (limited to 'trayfreq_set_interface.c') diff --git a/trayfreq_set_interface.c b/trayfreq_set_interface.c new file mode 100644 index 0000000..3e26112 --- /dev/null +++ b/trayfreq_set_interface.c @@ -0,0 +1,46 @@ +/************************************************************************ + * This file is part of trayfreq-archlinux. * + * * + * trayfreq-archlinux is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * trayfreq-archlinux is distributed in the hope that it will be useful,* + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with trayfreq-archlinux. If not, see * + * . * + ************************************************************************/ + +#include "trayfreq_set_interface.h" + +#include +#include + +void si_gov(char* gov, int core) +{ + char cmd[256]; + if (_DEFAULT_USE_SUDO) + { + sprintf(cmd, "sudo trayfreq-set -g %s -c %i",gov,core); + } else { + sprintf(cmd, "trayfreq-set -g %s -c %i",gov,core); + } + system(cmd); +} + +void si_freq(int freq, int core) +{ + char cmd[256]; + if (_DEFAULT_USE_SUDO) + { + sprintf(cmd, "sudo trayfreq-set -f %i -c %i",freq,core); + } else { + sprintf(cmd, "trayfreq-set -f %i -c %i",freq,core); + } + system(cmd); +} -- cgit v1.1 From 8e6c8cd0ad292386f1de8b22a9db060c11e5bbe6 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 10 May 2014 14:08:33 +1200 Subject: Fixed auto governor change bug --- trayfreq_set_interface.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'trayfreq_set_interface.c') diff --git a/trayfreq_set_interface.c b/trayfreq_set_interface.c index 3e26112..e64a88e 100644 --- a/trayfreq_set_interface.c +++ b/trayfreq_set_interface.c @@ -18,6 +18,8 @@ #include "trayfreq_set_interface.h" +#include "debug.h" + #include #include @@ -30,6 +32,7 @@ void si_gov(char* gov, int core) } else { sprintf(cmd, "trayfreq-set -g %s -c %i",gov,core); } + debug("Running '%s'\n",cmd); system(cmd); } @@ -42,5 +45,6 @@ void si_freq(int freq, int core) } else { sprintf(cmd, "trayfreq-set -f %i -c %i",freq,core); } + debug("Running '%s'\n",cmd); system(cmd); } -- cgit v1.1 From 75c186f2e6ad9dd37027f19bdb263daa83045e4b Mon Sep 17 00:00:00 2001 From: David Date: Sat, 10 May 2014 21:30:16 +1200 Subject: Header/includes tidy-up --- trayfreq_set_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'trayfreq_set_interface.c') diff --git a/trayfreq_set_interface.c b/trayfreq_set_interface.c index e64a88e..fc847e6 100644 --- a/trayfreq_set_interface.c +++ b/trayfreq_set_interface.c @@ -19,7 +19,7 @@ #include "trayfreq_set_interface.h" #include "debug.h" - +#include "defaults.h" #include #include -- cgit v1.1 From a04001bb863cc853c1f064c2eb91391fbc24dc1b Mon Sep 17 00:00:00 2001 From: David Date: Sat, 10 May 2014 22:35:00 +1200 Subject: Makefile options for portability --- trayfreq_set_interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'trayfreq_set_interface.c') diff --git a/trayfreq_set_interface.c b/trayfreq_set_interface.c index fc847e6..d16c160 100644 --- a/trayfreq_set_interface.c +++ b/trayfreq_set_interface.c @@ -28,9 +28,9 @@ void si_gov(char* gov, int core) char cmd[256]; if (_DEFAULT_USE_SUDO) { - sprintf(cmd, "sudo trayfreq-set -g %s -c %i",gov,core); + sprintf(cmd, SUDO" "TRAYFREQ_SET" -g %s -c %i",gov,core); } else { - sprintf(cmd, "trayfreq-set -g %s -c %i",gov,core); + sprintf(cmd, TRAYFREQ_SET" -g %s -c %i",gov,core); } debug("Running '%s'\n",cmd); system(cmd); @@ -41,9 +41,9 @@ void si_freq(int freq, int core) char cmd[256]; if (_DEFAULT_USE_SUDO) { - sprintf(cmd, "sudo trayfreq-set -f %i -c %i",freq,core); + sprintf(cmd, SUDO" "TRAYFREQ_SET" -f %i -c %i",freq,core); } else { - sprintf(cmd, "trayfreq-set -f %i -c %i",freq,core); + sprintf(cmd, TRAYFREQ_SET" -f %i -c %i",freq,core); } debug("Running '%s'\n",cmd); system(cmd); -- cgit v1.1 From 38f928b2f33ec527490899e580e5ee1327a327e9 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 4 Jun 2014 19:54:12 +1200 Subject: Moved away from manual setting of sudo-ness --- trayfreq_set_interface.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'trayfreq_set_interface.c') diff --git a/trayfreq_set_interface.c b/trayfreq_set_interface.c index d16c160..a2e20c8 100644 --- a/trayfreq_set_interface.c +++ b/trayfreq_set_interface.c @@ -18,33 +18,33 @@ #include "trayfreq_set_interface.h" -#include "debug.h" -#include "defaults.h" +#include "common.h" #include #include +#include void si_gov(char* gov, int core) { char cmd[256]; - if (_DEFAULT_USE_SUDO) + if (getuid() != ROOT_UID) { sprintf(cmd, SUDO" "TRAYFREQ_SET" -g %s -c %i",gov,core); } else { sprintf(cmd, TRAYFREQ_SET" -g %s -c %i",gov,core); } - debug("Running '%s'\n",cmd); + info("Running '%s'\n",cmd); system(cmd); } void si_freq(int freq, int core) { char cmd[256]; - if (_DEFAULT_USE_SUDO) + if (getuid() != ROOT_UID) { sprintf(cmd, SUDO" "TRAYFREQ_SET" -f %i -c %i",freq,core); } else { sprintf(cmd, TRAYFREQ_SET" -f %i -c %i",freq,core); } - debug("Running '%s'\n",cmd); + info("Running '%s'\n",cmd); system(cmd); } -- cgit v1.1 From ef004666027cd8fc3854ced9f126ae3ab0ce28f9 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 4 Jun 2014 20:46:32 +1200 Subject: Sudo prompt halt fix --- trayfreq_set_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'trayfreq_set_interface.c') diff --git a/trayfreq_set_interface.c b/trayfreq_set_interface.c index a2e20c8..592c8c5 100644 --- a/trayfreq_set_interface.c +++ b/trayfreq_set_interface.c @@ -28,7 +28,7 @@ void si_gov(char* gov, int core) char cmd[256]; if (getuid() != ROOT_UID) { - sprintf(cmd, SUDO" "TRAYFREQ_SET" -g %s -c %i",gov,core); + sprintf(cmd, SUDO" -n "TRAYFREQ_SET" -g %s -c %i &",gov,core); } else { sprintf(cmd, TRAYFREQ_SET" -g %s -c %i",gov,core); } @@ -41,7 +41,7 @@ void si_freq(int freq, int core) char cmd[256]; if (getuid() != ROOT_UID) { - sprintf(cmd, SUDO" "TRAYFREQ_SET" -f %i -c %i",freq,core); + sprintf(cmd, SUDO" -n "TRAYFREQ_SET" -f %i -c %i &",freq,core); } else { sprintf(cmd, TRAYFREQ_SET" -f %i -c %i",freq,core); } -- cgit v1.1 From de88a7b12c2fccd7989655629afc9d6de4dc7b66 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 12 Jun 2014 17:25:40 +1200 Subject: Adjusted max command length to (effectively) infinity --- trayfreq_set_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'trayfreq_set_interface.c') diff --git a/trayfreq_set_interface.c b/trayfreq_set_interface.c index 592c8c5..df168c6 100644 --- a/trayfreq_set_interface.c +++ b/trayfreq_set_interface.c @@ -25,7 +25,7 @@ void si_gov(char* gov, int core) { - char cmd[256]; + char cmd[1024]; if (getuid() != ROOT_UID) { sprintf(cmd, SUDO" -n "TRAYFREQ_SET" -g %s -c %i &",gov,core); @@ -38,7 +38,7 @@ void si_gov(char* gov, int core) void si_freq(int freq, int core) { - char cmd[256]; + char cmd[1024]; if (getuid() != ROOT_UID) { sprintf(cmd, SUDO" -n "TRAYFREQ_SET" -f %i -c %i &",freq,core); -- cgit v1.1