summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO18
-rw-r--r--PKGBUILD21
-rw-r--r--osu-file-extensions-handler.desktop8
-rw-r--r--osu-handler.install11
-rwxr-xr-xosu-wine.py43
5 files changed, 101 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..74c81e229de7
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,18 @@
+pkgbase = osu-handler
+ pkgdesc = Provides a handler for osu! file formats
+ pkgver = 0.1
+ pkgrel = 1
+ install = osu-handler.install
+ arch = any
+ license = AGPL3
+ depends = osu-mime
+ depends = desktop-file-utils
+ depends = python
+ depends = libnotify
+ source = osu-wine.py
+ source = osu-file-extensions-handler.desktop
+ sha256sums = a2b57b360c508dc195bd8b1fd95c69b8f007ec3a22eda894d8ac234356ff8d44
+ sha256sums = b629d7f99652bb96bc8f381dde7e455ba66fc1b69b472ee7762b7f5a1f641dc8
+
+pkgname = osu-handler
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..063f272a8196
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Torge Matthies <openglfreak at googlemail dot com>
+
+pkgname=osu-handler
+pkgdesc='Provides a handler for osu! file formats'
+pkgver=0.1
+pkgrel=1
+arch=(any)
+license=(AGPL3)
+depends=(osu-mime desktop-file-utils python libnotify)
+install='osu-handler.install'
+source=(osu-wine.py
+ osu-file-extensions-handler.desktop)
+sha256sums=('a2b57b360c508dc195bd8b1fd95c69b8f007ec3a22eda894d8ac234356ff8d44'
+ 'b629d7f99652bb96bc8f381dde7e455ba66fc1b69b472ee7762b7f5a1f641dc8')
+
+package() {
+ cd "$pkgdir"
+
+ install -D -m755 "$srcdir/osu-wine.py" 'usr/lib/osu-mime/osu-wine'
+ install -D -m644 "$srcdir/osu-file-extensions-handler.desktop" 'usr/share/applications/osu-file-extensions-handler.desktop'
+}
diff --git a/osu-file-extensions-handler.desktop b/osu-file-extensions-handler.desktop
new file mode 100644
index 000000000000..3a2aa8b3d9e3
--- /dev/null
+++ b/osu-file-extensions-handler.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=osu!
+MimeType=application/x-osu-skin;application/x-osu-replay;application/x-osu-archive;
+Exec=/usr/lib/osu-mime/osu-wine start /ProgIDOpen osu! %f
+NoDisplay=true
+StartupNotify=true
+Icon=osu!
diff --git a/osu-handler.install b/osu-handler.install
new file mode 100644
index 000000000000..5728b2bc7ab0
--- /dev/null
+++ b/osu-handler.install
@@ -0,0 +1,11 @@
+post_install() {
+ update-desktop-database -q
+}
+
+post_upgrade() {
+ post_install "$@"
+}
+
+post_remove() {
+ post_install "$@"
+}
diff --git a/osu-wine.py b/osu-wine.py
new file mode 100755
index 000000000000..077ac39f7ffa
--- /dev/null
+++ b/osu-wine.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python3
+import sys
+import os
+
+def prog_paths():
+ with os.scandir('/proc') as sd:
+ for entry in sd:
+ if entry.name.isdecimal() and entry.is_dir(follow_symlinks=False):
+ yield entry
+
+def main(args):
+ uid = os.getuid()
+
+ for dirent in prog_paths():
+ try:
+ if dirent.stat().st_uid != uid:
+ continue
+
+ with open(dirent.path + '/comm', 'rb') as file:
+ if file.read() != b'osu!.exe\n':
+ continue
+
+ exe_path = os.readlink(dirent.path + '/exe')
+ if not exe_path.endswith('/wine-preloader'):
+ continue
+ wine_path = exe_path[:-len('-preloader')]
+
+ with open(dirent.path + '/environ', 'rb') as file:
+ environ = file.read()
+ environ = environ.split(b'\0')
+ environ = environ[:-1]
+ environ = dict(x.split(b'=', maxsplit=1) for x in environ)
+
+ del environ[b'WINELOADERNOEXEC']
+ os.execve(wine_path, [wine_path] + args, environ)
+ except OSError:
+ pass
+
+ os.execl('/usr/bin/notify-send', 'notify-send', '-i', 'osu!', '-a', 'osu!',
+ 'No running osu! instance found')
+
+if __name__ == '__main__':
+ main(sys.argv[1:])