55 Commits

Author SHA1 Message Date
Ahsan Fayaz
5b3b4ae638 Add "GameMode contributors" to copyright notice
Attribute the contributions made by members of the community, but avoid
unweildy and inconsistent copyright notices at the top of each file.

Existing contributor copyright notices have been left as-is.
2025-02-24 15:14:21 +00:00
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
James Le Cuirot
b103bfdd60 Don't force installation of static libgamemodeauto
Defining the library with `library` rather than `both_libraries` allows the user
to choose which type they want to install using `-Ddefault_library`.

Closes: https://github.com/FeralInteractive/gamemode/issues/287
2022-10-04 15:44:23 +01: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
Stephan Lachnit
9b44fc6def ci: fix static analyser with assertions
Signed-off-by: Stephan Lachnit <stephanlachnit@debian.org>
2022-07-15 14:17:38 +01:00
Stephan Lachnit
8b408694b0 improve libgamemodeauto pkg-config file
Rename the pkg-config entry for libgamemodeauto, to it make it more that this will link against a library, compared to what the `gamemode` pkg-config does. This also removes the manual addition of the libdl dependency, this is done by Meson automatically.

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-06-23 09:18:14 +01:00
Stephan Lachnit
d8337aeb05 various variable naming improvements
This makes it more clear that libgamemode and libgamemodeauto are indeed libraries. Also, the misleading name `libgamemode_dep` has been renamed to `gamemode_dep`, which now also includes the dependency on libdl. The misleading `libgamemode_includes` variable name has also been changed.

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-06-23 09:18:14 +01:00
Stephan Lachnit
d4536c62af build gamemodeauto also as static library
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-06-23 09:18:14 +01:00
Stephan Lachnit
9ecff8d5d3 Meson: explicitly set include path
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-05-20 10:00:18 +01:00
Stephan Lachnit
f7a4a6ccfe expose dependency objects for libs
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-05-12 19:25:57 +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
Marc Di Luzio
28243afde9 Clean up the main readme file and split some parts out
This groups development, daemon and lib parts together much better
2019-06-01 10:56: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
Alex Smith
b04e39df43 Merge pull request #143 from mdiluz/client-example-check
Small client header improvements
2019-05-19 11:06:48 +01:00
Marc Di Luzio
f41ecda047 Fix a missing e 2019-05-15 18:58:12 +01:00
Marc Di Luzio
ddecc89f10 Add a note about GAMEMODE_AUTO and blocking calls 2019-05-15 18:56:14 +01:00
Marc Di Luzio
ddc802573a Remove unneeded includes in gamemode_client.h 2019-05-15 18:56:14 +01:00
Marc Di Luzio
a482b72d37 Fix comments in gamemode_client.h 2019-05-11 12:08:29 +01: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
0f7950245a Actually don't error if a symbol is not required 2019-02-21 17:34:20 +00:00
Marc Di Luzio
ca858d6932 Add two new API calls to the client to request gamemode on behalf of another process
gamemode_request_start_for and gamemode_request_end_for
2019-02-21 17:34:20 +00:00
Marc Di Luzio
1f49432e7a Simplify the typedefs for the apicalls 2019-02-21 17:34:20 +00:00
Alex Smith
7051051f19 Attempt to load unversioned library for compatibility with older installations
Games built against a new gamemode_client.h will fail to work with older
GameMode installations without this change. There are no ABI changes right
now so just attempt to load the old unversioned path if loading the
versioned one fails.
2018-07-23 10:21:31 +01:00
Christian Kellner
8f8a6d4f91 lib: dlopen versioned library
Instead of dlopen'ing the plain, not versioned library, use the
versioned one with current interface, i.e. 0: libgamemode.so.0
2018-07-02 14:02:23 +02:00
Christian Kellner
ea3e135ae0 lib: use libtool like versioning
In order to be safe for future ABI changes and to fulfill packaging
requirements for e.g. Fedora, provide libtool like versioning for
both libraries, i.e. libgamemode and libgamemodeauto.
2018-07-02 13:59:18 +02:00
Christian Kellner
a4b98e61bf lib: generate a pkg-config files
To ease development, create a gamemode.pc and a gamemode-auto.pc
file, that other projects can use integrate with gamemode. The
former if they want to integrate at the source level and the latter
if the automatic integration is preferred.
2018-07-02 13:53:10 +02:00
Marc Di Luzio
eac854b753 Allow failure when finding functions that are new to the API
This allows a game using a newer client header than the installed gamemode to still function
2018-04-25 15:24:07 +01: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
Marc Di Luzio
d9727e9d38 Rename variables and functions that had an underscore prefix
Ensures we conform better to C standards
2018-04-16 17:42:54 +01:00
Leonard
752d877196 Minor C cleanup (#27)
* Minor C cleanup

 - some symbols can be made static:
    1. set_gov_state
    2. everything in gamemode_client.h
 - daemonize() can also take a const char*, since the name is only
   passed to printf() or syslog()
 - prevent shadowing of variables
 - use explicit (void) as parameter-list more consistently
 - use some more const.
   Move cast to more appropriate place and document that execv() behaves
   as if args where of type const *char and we trust on that.
 - example: Just use main(void), which is also an acceptable ISO-C decl
 - example: Use stderr for errors

* Fix -Wold-style-declaration issue
2018-04-16 17:21:35 +01:00
Marc Di Luzio
9bb3ebf34b Fixes for #23 and #24, violations of the C standard 2018-04-12 10:47:42 +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