Compare commits

...

2 commits

Author SHA1 Message Date
2aedbced66
Automatically detect loaded module. 2024-04-15 17:47:15 +02:00
7af9381e6e
Initial implementation. 2024-04-15 17:32:35 +02:00
5 changed files with 51 additions and 1 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
pkg/
src/
sway-dynamic-*/
sway-dynamic-*.pkg.tar.zst

17
PKGBUILD Normal file
View file

@ -0,0 +1,17 @@
# Maintainer redxef <redxef@redxef.at>
pkgname=sway-dynamic
pkgver=1.0.1
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"
}

View file

@ -1,3 +1,9 @@
# sway-dynamic
Dynamically switch between sway and sway-nvidia based on active gpu.
## Usage
Blacklist the module which should not be loaded on boot, the script
detects if the `nvidia` or `nouveau` driver is loaded and either calls
`sway-nvidia` or `sway`.

18
sway-dynamic Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh
active_module() {
if [ -n "$(lsmod | grep "nvidia")" ]; then
echo "nvidia"
elif [ -n "$(lsmod | grep "nouveau")" ]; then
echo nouveau
else
# no nvidia modules loaded
echo ""
fi
}
if [ "$(active_module)" = 'nvidia' ]; then
exec sway-nvidia
else
exec sway
fi

5
sway-dynamic.desktop Normal file
View file

@ -0,0 +1,5 @@
[Desktop Entry]
Name=Sway (Dynamic)
Comment=An i3-compatible Wayland compositor (NVIDIA Fixes or Standard)
Exec=sway-dynamic
Type=Application