From 7af9381e6e6a5598e2d12b18d5f78264511fa589 Mon Sep 17 00:00:00 2001 From: redxef Date: Mon, 15 Apr 2024 17:31:37 +0200 Subject: [PATCH] Initial implementation. --- PKGBUILD | 17 +++++++++++++++++ README.md | 13 ++++++++++++- sway-dynamic | 7 +++++++ sway-dynamic.desktop | 5 +++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 PKGBUILD create mode 100755 sway-dynamic create mode 100644 sway-dynamic.desktop diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..a2a1387 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,17 @@ +# Maintainer redxef +pkgname=sway-dynamic +pkgver=1.0.0 +pkgrel=1 +pkgdesc="Helper files to dynamically launch sway for NVIDIA comaptibility or not" +arch=('any') +url="https://gitea.redxef.at/redxef/sway-dynamic" +license=('MIT') +depends=('sway' 'sway-nvidia') +source=("$pkgname-$pkgver::git+$url.git#tag=v$pkgver") +sha256sums=('SKIP') + +package() { + cd "$pkgname-$pkgver" + install -Dm755 sway-dynamic "$pkgdir/usr/bin/sway-dynamic" + install -Dm644 sway-dynamic.desktop "$pkgdir/usr/share/wayland-sessions/sway-dynamic.desktop" +} diff --git a/README.md b/README.md index 0531320..dc01ec0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # sway-dynamic -Dynamically switch between sway and sway-nvidia based on active gpu. \ No newline at end of file +Dynamically switch between sway and sway-nvidia based on active gpu. + +## Usage + +When booting a GPU set the environment variable `GPUMODE=` with something +like `systemd.setenv=GPUMODE=`. The script will decide how to +launch sway depending on this variable. Possible values: + +- `nvidia` +- `nouveau` + + diff --git a/sway-dynamic b/sway-dynamic new file mode 100755 index 0000000..5b850cb --- /dev/null +++ b/sway-dynamic @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ "$GPUMODE" = 'nvidia' ]; then + exec sway-nvidia +else + exec sway +fi diff --git a/sway-dynamic.desktop b/sway-dynamic.desktop new file mode 100644 index 0000000..abb014b --- /dev/null +++ b/sway-dynamic.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Sway (Dynamic) +Comment=An i3-compatible Wayland compositor (NVIDIA Fixes or Standard) +Exec=sway-dynamic +Type=Application