aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMily <[email protected]>2023-07-23 15:51:00 -0300
committerGitHub <[email protected]>2023-07-23 20:51:00 +0200
commit9fc5f4c48b20875337b7a1eddd274f191edd504d (patch)
tree5f5800f5256829be4c6cc644343a1f33f20b681a
parent50e6f368fffece098bea4f0cd87ce3d555ab2cbd (diff)
downloadHyprland-9fc5f4c48b20875337b7a1eddd274f191edd504d.tar.gz
Hyprland-9fc5f4c48b20875337b7a1eddd274f191edd504d.zip
init: Request SCHED_RR using CAP_SYS_NICE and add Python to nix dev shell (#2690)
* nix: add python3 to devShell * init: request SCHED_RR scheduling policy * init: checks if host supports reseting scheduler on fork * init: make gainRealTime more compatible with other OSes * init: remove linux-only code
-rw-r--r--flake.nix2
-rw-r--r--src/init/initHelpers.cpp16
-rw-r--r--src/init/initHelpers.hpp1
-rw-r--r--src/main.cpp1
4 files changed, 19 insertions, 1 deletions
diff --git a/flake.nix b/flake.nix
index fc595c3d..dac4d69b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -77,7 +77,7 @@
devShells = genSystems (system: {
default = pkgsFor.${system}.mkShell {
name = "hyprland-shell";
- nativeBuildInputs = with pkgsFor.${system}; [cmake];
+ nativeBuildInputs = with pkgsFor.${system}; [ cmake python3 ];
buildInputs = [self.packages.${system}.wlroots-hyprland];
inputsFrom = [
self.packages.${system}.wlroots-hyprland
diff --git a/src/init/initHelpers.cpp b/src/init/initHelpers.cpp
index dc51650a..2666ed0b 100644
--- a/src/init/initHelpers.cpp
+++ b/src/init/initHelpers.cpp
@@ -3,3 +3,19 @@
bool Init::isSudo() {
return getuid() != geteuid() || !geteuid();
}
+
+void Init::gainRealTime() {
+ const int minPrio = sched_get_priority_min(SCHED_RR);
+ const struct sched_param param = {.sched_priority = minPrio};
+
+ if (pthread_setschedparam(pthread_self(), SCHED_RR, &param)) {
+ Debug::log(WARN, "Failed to change process scheduling strategy");
+ return;
+ }
+
+ pthread_atfork(NULL, NULL, []() {
+ const struct sched_param param = {.sched_priority = 0};
+ if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &param))
+ Debug::log(WARN, "Failed to reset process scheduling strategy");
+ });
+} \ No newline at end of file
diff --git a/src/init/initHelpers.hpp b/src/init/initHelpers.hpp
index 3b9f7915..da9b762a 100644
--- a/src/init/initHelpers.hpp
+++ b/src/init/initHelpers.hpp
@@ -4,4 +4,5 @@
namespace Init {
bool isSudo();
+ void gainRealTime();
}; \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 4fcc611f..4d3d6474 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -89,6 +89,7 @@ int main(int argc, char** argv) {
}
std::cout << "Welcome to Hyprland!\n";
+ Init::gainRealTime();
// let's init the compositor.
// it initializes basic Wayland stuff in the constructor.