diff --git a/README.md b/README.md index 2d85987..0fc1a9b 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,5 @@ This is a plugin for the [SteamOS Plugin Loader](https://github.com/SteamDeckHom ## Features -- Toggling the SSH server on and off \ No newline at end of file +- Toggling the SSH server on and off +- Toggling Transparent Huge Pages on and off, which [can improve gaming performance](https://www.reddit.com/r/linux_gaming/comments/uhfjyt/underrated_advice_for_improving_gaming/). diff --git a/main.py b/main.py index 1be1152..9db578c 100644 --- a/main.py +++ b/main.py @@ -9,5 +9,20 @@ async def set_ssh_state(self, state): subprocess.Popen("systemctl enable --now sshd", stdout=subprocess.PIPE, shell=True).wait() else: subprocess.Popen("systemctl disable --now sshd", stdout=subprocess.PIPE, shell=True).wait() - - return await self.get_ssh_state(self) \ No newline at end of file + + return await self.get_ssh_state(self) + + async def set_thp_state(self, state): + if state: + with open("/sys/kernel/mm/transparent_hugepage/enabled", "w") as f: + f.write("always") + else: + with open("/sys/kernel/mm/transparent_hugepage/enabled", "w") as f: + f.write("madvise") + + return await self.get_thp_state(self) + + + async def get_thp_state(self): + with open("/sys/kernel/mm/transparent_hugepage/enabled", "r") as f: + return f.read().strip().startswith("[always]") diff --git a/main_view.html b/main_view.html index 95ba0a4..d5e81df 100644 --- a/main_view.html +++ b/main_view.html @@ -7,7 +7,7 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -61,10 +82,26 @@
SSH Server
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Transparent Huge Pages +
+
+
+
+
+