28 Commits

Author SHA1 Message Date
Trial97
3fa41891cf Fixed crash if dbus is not accesible
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
2024-02-14 10:33:22 +00:00
ashuntu
4cffdef805 Removed blank line 2022-09-14 17:57:49 +01:00
ashuntu
3f969bbf1f Fix env edgecase 2022-09-14 17:57:49 +01:00
ashuntu
1ca2daf47f Make more readable 2022-09-14 17:57:49 +01:00
ashuntu
179d5432e4 Add snap support 2022-09-14 17:57:49 +01:00
Christian Kellner
6f7df91b60 lib: support the new pidfd based APIs
Try to make API requests using the new pidfd based APIs. If getting
the pidfds fails or if the remote (daemon) does not support the new
pidfd based D-Bus API, transparently fall back to the old API.
2019-10-21 16:20:22 +02:00
Christian Kellner
b513bc65ae lib: extract dbus messaging code
Separate the D-Bus messaging code from gamemode_request().
2019-10-18 13:19:30 +02:00
Christian Kellner
f6220a2d6e lib: do flatpak check only once
Either we are in a flatpak or not, this doesn't change, so we can
just remember the result.
2019-10-18 13:19:30 +02:00
Alex Smith
b0c36c0eaa Remove unused LOG_ERROR, always log errors 2019-06-01 13:49:37 +01:00
Alex Smith
2a124ce8c7 Merge pull request #151 from mdiluz/patch-1
Turn off debug logging in client impl
2019-06-01 13:46:06 +01:00
Marc Di Luzio
a5e00bc94e Turn off debug logging in client impl
Accidentally left in #147
2019-06-01 11:00:33 +01:00
Marc Di Luzio
2e67906402 Remove unneeded includes 2019-06-01 10:57:27 +01:00
Christian Kellner
e87a8f19f3 lib: use libdbus for client's dbus messaging
Switch the dbus implementation for the client from systemd to
libdbus. The main reason is that, in flatpaks systemd is not easily
available. No phenomenological change for users of the library,
hopefully.
2019-05-27 13:44:44 +02:00
Christian Kellner
0c36f3a6b0 Talk to the portal when running inside a flatpak
When we detect that we are running inside a flatpak, talk to the
flatpak portal D-Bus service instead of the session daemon. This
is necessary because flatpak uses pid namespace isolation (see
man pid_namespaces(7)) and thus the pid needs to be translated
from the flatpak pid namespace to the host namespace. This
translation is happening inside the GameMode xdg-desktop-portal.
2019-05-21 00:34:45 +02:00
Christian Kellner
536d687c9a Use defines for dbus name, path, interface
That gives some meaning to the strings and makes it easier to see
what the arguments of sd_bus_call_method mean without checking the
function docs.
2019-05-20 14:39:09 +02:00
Christian Kellner
393a5e8f41 lib: release acquired bus reference
On each gamemode_request call a new connection to d-bus is opened
but the reference was never release thus leaking the connection
and associated memory.
2019-04-30 11:46:50 +02:00
Alex Smith
10a31f8dec Update copyright years to 2019 2019-03-14 16:59:30 +00:00
Marc Di Luzio
e44c445262 Use the actual dbus error when failing in the client
This helps greatly when identifying what went wrong
2019-03-07 17:51:57 +00:00
Marc Di Luzio
b28efdb555 Correct the names and return 0 for success 2019-02-21 17:34:20 +00:00
Marc Di Luzio
d4fdd9e3b4 Correct internal name for query_status_for 2019-02-21 17:34:20 +00:00
Marc Di Luzio
c2f7e971c6 Implement game_mode_query_status_for as well 2019-02-21 17:34:20 +00:00
Marc Di Luzio
c5f58c56d0 Hook up interfaces for functions to register another process 2019-02-21 17:34:20 +00:00
Marc Di Luzio
4f3bc2c9a2 Add gamemode_query_status and teach gamemoded '-s'
This allows the client to query the daemon about the status of gamemode.

	Returns the following:
		 0 if gamemode is inactive
		 1 if gamemode is active
		 2 if gamemode is active and this client is registered
		-1 if the query failed

	Passing -s to gamemoded will simply query and print the current status.

	Allows for more comprehensive testing when using 'gamemoded -r' as well as more reactionary program behaviour
2018-04-25 14:51:38 +01:00
Ikey Doherty
8fb77e639d Ensure to set _GNU_SOURCE for POSIX compliance with signals
The systemd bus headers aren't setting a POSIX compliance level so we
define the catch-all to ensure the build doesn't error out, as seen with
issue #3. This is due to the reliance of `siginfo_t`, which requires a
minimum POSIX level of `199309L` when using glibc.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-04-10 14:09:39 +01:00
Ikey Doherty
69db9c2a61 Conformance: Update copyright range to include 2018
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-04-10 13:23:38 +01:00
Ikey Doherty
e90bd98d64 Enforce strict compiler warnings
This exposed a bunch of issues that needed dealing with to ensure the
code is clean and sane. Notably the dlopen/dlsym routine has been altered
to closer match the LSI approach of safe symbol binding, by not attempting
to directly cast the result of a dlsym operation. Instead, if we succeed
in getting the dlsym() pointer, we memcpy this to the target and ensure
we have the correct constraints.

Note that in sanitizing the log helpers, I opted to remove the varargs
ability from FATAL_ERRNO given this is used exactly like perror() and
there are no examples currently using varargs with this in the tree.
This allowed me to keep the log helpers as macros and not have to implement
wrapper functions.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:26 +00:00
Marc Di Luzio
2bbaab129b Apply clang format to files
Also add brackets for all scopes at the same time
2018-03-05 17:32:01 +00:00
Marc Di Luzio
c459c05076 Initial 0.1 commit
This is a small daemon/libary to enable games to request a
performance "game mode" from the system.

Currently only implemented to upgrade the CPU governor and
automatically downgrade it once done.

A game only needs to load libgamemodeauto to activate the request.
Which means an LD_PRELOAD can be applied to any game to activate
the mode as needed.

However gamemode_client.h can be used to manually activate/deactivate
the mode as needed, and also perform error checking.

The libs are miminal loaders to call into an installed libgamemode
which, if the daemon is installed and running, will send through
the equivelant game mode request, and magic will happen.

See the README.md for more details.

Currently licensed under the BSD 3 clause license.
2018-03-05 17:32:01 +00:00