mirror of
https://github.com/EnderIce2/rpc-bridge.git
synced 2025-07-09 14:29:15 +00:00
Compare commits
5 Commits
v1.0
...
56168a6d3d
Author | SHA1 | Date | |
---|---|---|---|
56168a6d3d
|
|||
d2b23eb2e8
|
|||
cba4fa1e2b
|
|||
8c7b336c0e | |||
334c4e0479
|
16
README.md
16
README.md
@ -1,5 +1,9 @@
|
|||||||
# Discord RPC Bridge for Wine
|
# Discord RPC Bridge for Wine
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
Simple bridge that allows you to use Discord Rich Presence with Wine games/software.
|
Simple bridge that allows you to use Discord Rich Presence with Wine games/software.
|
||||||
|
|
||||||
Works by running a small program in the background that creates a [named pipe](https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipes) `\\.\pipe\discord-ipc-0` inside the prefix and forwards all data to the pipe `/run/user/1000/discord-ipc-0`.
|
Works by running a small program in the background that creates a [named pipe](https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipes) `\\.\pipe\discord-ipc-0` inside the prefix and forwards all data to the pipe `/run/user/1000/discord-ipc-0`.
|
||||||
@ -13,11 +17,11 @@ This bridge takes advantage of the Windows service implementation in Wine, elimi
|
|||||||
- [Discord RPC Bridge for Wine](#discord-rpc-bridge-for-wine)
|
- [Discord RPC Bridge for Wine](#discord-rpc-bridge-for-wine)
|
||||||
- [Table of Contents](#table-of-contents)
|
- [Table of Contents](#table-of-contents)
|
||||||
- [Installation \& Usage](#installation--usage)
|
- [Installation \& Usage](#installation--usage)
|
||||||
- [Installing inside a prefix](#installing-inside-a-prefix)
|
- [Installing inside a prefix](#installing-inside-a-prefix)
|
||||||
- [Wine (~/.wine)](#wine-wine)
|
- [Wine (~/.wine)](#wine-wine)
|
||||||
- [Lutris](#lutris)
|
- [Lutris](#lutris)
|
||||||
- [Steam](#steam)
|
- [Steam](#steam)
|
||||||
- [If you use Flatpak](#if-you-use-flatpak)
|
- [If you use Flatpak](#if-you-use-flatpak)
|
||||||
- [Run without installing the service](#run-without-installing-the-service)
|
- [Run without installing the service](#run-without-installing-the-service)
|
||||||
- [Compiling from source](#compiling-from-source)
|
- [Compiling from source](#compiling-from-source)
|
||||||
- [Command line arguments](#command-line-arguments)
|
- [Command line arguments](#command-line-arguments)
|
||||||
@ -76,7 +80,7 @@ If you prefer not to use the service for any reason, please refer to the [Run wi
|
|||||||
|
|
||||||
## Run without installing the service
|
## Run without installing the service
|
||||||
|
|
||||||
If you prefer not to use the service, you can manually run `bridge.exe`` within the Wine prefix.
|
If you prefer not to use the service, you can manually run `bridge.exe` within the Wine prefix.
|
||||||
This method is compatible with both Wine and Lutris.
|
This method is compatible with both Wine and Lutris.
|
||||||
|
|
||||||
In Lutris, you can achieve this by adding the path to `bridge.exe` in the `Executable` field under `Game options`. In `Arguments` field, be sure to include the _Windows_ path to the game's executable.
|
In Lutris, you can achieve this by adding the path to `bridge.exe` in the `Executable` field under `Game options`. In `Arguments` field, be sure to include the _Windows_ path to the game's executable.
|
||||||
|
8
bridge.c
8
bridge.c
@ -10,6 +10,9 @@
|
|||||||
#define __NR_close 6
|
#define __NR_close 6
|
||||||
#define __NR_socketcall 102
|
#define __NR_socketcall 102
|
||||||
|
|
||||||
|
#define SYS_SOCKET 1
|
||||||
|
#define SYS_CONNECT 3
|
||||||
|
|
||||||
#define O_RDONLY 00
|
#define O_RDONLY 00
|
||||||
|
|
||||||
#define likely(expr) (__builtin_expect(!!(expr), 1))
|
#define likely(expr) (__builtin_expect(!!(expr), 1))
|
||||||
@ -136,6 +139,7 @@ void ConnectToSocket(int fd)
|
|||||||
|
|
||||||
print("XDG_RUNTIME_DIR: %s\n", runtime);
|
print("XDG_RUNTIME_DIR: %s\n", runtime);
|
||||||
|
|
||||||
|
/* TODO: check for multiple discord instances and create a pipe for each */
|
||||||
const char *discordUnixPipes[] = {
|
const char *discordUnixPipes[] = {
|
||||||
"/discord-ipc-0",
|
"/discord-ipc-0",
|
||||||
"/snap.discord/discord-ipc-0",
|
"/snap.discord/discord-ipc-0",
|
||||||
@ -161,7 +165,7 @@ void ConnectToSocket(int fd)
|
|||||||
(unsigned long)&socketAddr,
|
(unsigned long)&socketAddr,
|
||||||
sizeof(socketAddr)};
|
sizeof(socketAddr)};
|
||||||
|
|
||||||
sockRet = sys_socketcall(3, socketArgs);
|
sockRet = sys_socketcall(SYS_CONNECT, socketArgs);
|
||||||
|
|
||||||
free(pipePath);
|
free(pipePath);
|
||||||
if (sockRet >= 0)
|
if (sockRet >= 0)
|
||||||
@ -372,7 +376,7 @@ NewConnection:
|
|||||||
(unsigned long)SOCK_STREAM,
|
(unsigned long)SOCK_STREAM,
|
||||||
0};
|
0};
|
||||||
|
|
||||||
int fd = sys_socketcall(1, socketArgs);
|
int fd = sys_socketcall(SYS_SOCKET, socketArgs);
|
||||||
|
|
||||||
print("Socket %d created\n", fd);
|
print("Socket %d created\n", fd);
|
||||||
|
|
||||||
|
17
main.c
17
main.c
@ -52,6 +52,23 @@ void DetectWine()
|
|||||||
GetErrorMessage(), MB_OK | MB_ICONINFORMATION);
|
GetErrorMessage(), MB_OK | MB_ICONINFORMATION);
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void(CDECL * wine_get_host_version)(const char **sysname, const char **release);
|
||||||
|
wine_get_host_version = (void *)GetProcAddress(hNTdll, "wine_get_host_version");
|
||||||
|
|
||||||
|
assert(wine_get_host_version);
|
||||||
|
const char *__sysname;
|
||||||
|
const char *__release;
|
||||||
|
wine_get_host_version(&__sysname, &__release);
|
||||||
|
if (strcmp(__sysname, "Linux") != 0)
|
||||||
|
{
|
||||||
|
int result = MessageBox(NULL, "This program is designed for Linux only!\nDo you want to proceed?",
|
||||||
|
NULL, MB_YESNO | MB_ICONQUESTION);
|
||||||
|
if (result == IDYES)
|
||||||
|
return;
|
||||||
|
else if (result == IDNO)
|
||||||
|
ExitProcess(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(char const *fmt, ...)
|
void print(char const *fmt, ...)
|
||||||
|
Reference in New Issue
Block a user