architect: add modelines and resolution switching script to sunshine
This commit is contained in:
parent
9b21c7d2ef
commit
60534b7b05
@ -2,13 +2,38 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
user = "sunshine";
|
user = "sunshine";
|
||||||
|
resolutionScript = pkgs.writeTextFile {
|
||||||
|
name = "sunshine-resolution-script";
|
||||||
|
text = ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
width=''${1:-1920}
|
||||||
|
height=''${2:-1080}
|
||||||
|
refresh_rate=''${3:-120}
|
||||||
|
|
||||||
|
# Get the modeline info from the 2nd row in the cvt output
|
||||||
|
modeline=$(cvt ''${width} ''${height} ''${refresh_rate} | gawk 'FNR == 2')
|
||||||
|
xrandr_mode_str=''${modeline//Modeline \"*\" /}
|
||||||
|
mode_alias="''${width}x''${height}"
|
||||||
|
|
||||||
|
echo "xrandr setting new mode ''${mode_alias} ''${xrandr_mode_str}"
|
||||||
|
xrandr --rmmode ''${mode_alias}
|
||||||
|
xrandr --newmode ''${mode_alias} ''${xrandr_mode_str}
|
||||||
|
xrandr --addmode DP-0 ''${mode_alias}
|
||||||
|
|
||||||
|
# Apply new xrandr mode
|
||||||
|
xrandr --output DP-0 --primary --mode ''${mode_alias} --pos 0x0 --rotate normal
|
||||||
|
'';
|
||||||
|
executable = true;
|
||||||
|
destination = "/bin/resolution.sh";
|
||||||
|
};
|
||||||
configFile = pkgs.writeText "sunshine.conf"
|
configFile = pkgs.writeText "sunshine.conf"
|
||||||
''
|
''
|
||||||
output_name=1
|
output_name=1
|
||||||
origin_web_ui_allowed=lan
|
origin_web_ui_allowed=lan
|
||||||
channels=2
|
channels=2
|
||||||
min_threads=12
|
min_threads=12
|
||||||
global_prep_cmd=[{"do":"/run/current-system/sw/bin/sh -c \"/run/current-system/sw/bin/xrandr --output DP-0 --mode \"''${SUNSHINE_CLIENT_WIDTH}x''${SUNSHINE_CLIENT_HEIGHT}\" --rate ''${SUNSHINE_CLIENT_FPS}\""}]
|
global_prep_cmd=[{"do":"${pkgs.bash}/bin/bash -c \"${resolutionScript}/bin/resolution.sh ''${SUNSHINE_CLIENT_WIDTH} ''${SUNSHINE_CLIENT_HEIGHT} ''${SUNSHINE_CLIENT_FPS}\""}]
|
||||||
'';
|
'';
|
||||||
sunshineOverride = pkgs.sunshine.override { cudaSupport = true; stdenv = pkgs.cudaPackages.backendStdenv; };
|
sunshineOverride = pkgs.sunshine.override { cudaSupport = true; stdenv = pkgs.cudaPackages.backendStdenv; };
|
||||||
in
|
in
|
||||||
@ -38,9 +63,9 @@ in
|
|||||||
sunshineOverride
|
sunshineOverride
|
||||||
xorg.xrandr
|
xorg.xrandr
|
||||||
xorg.xorgserver
|
xorg.xorgserver
|
||||||
|
xorg.libxcvt
|
||||||
];
|
];
|
||||||
sound.enable = true;
|
sound.enable = true;
|
||||||
hardware.pulseaudio.enable = true;
|
|
||||||
|
|
||||||
services.xserver = {
|
services.xserver = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@ -63,6 +88,19 @@ in
|
|||||||
HorizSync 5.0 - 1000.0
|
HorizSync 5.0 - 1000.0
|
||||||
VertRefresh 5.0 - 1000.0
|
VertRefresh 5.0 - 1000.0
|
||||||
Option "DPMS"
|
Option "DPMS"
|
||||||
|
|
||||||
|
# 2240x1290 @ 30.00 Hz (GTF) hsync: 39.39 kHz; pclk: 113.44 MHz
|
||||||
|
Modeline "2240x1290_30.00" 113.44 2240 2328 2560 2880 1290 1291 1294 1313 -HSync +Vsync
|
||||||
|
# 2240x1290 @ 60.00 Hz (GTF) hsync: 80.10 kHz; pclk: 243.50 MHz
|
||||||
|
Modeline "2240x1290_60.00" 243.50 2240 2400 2640 3040 1290 1291 1294 1335 -HSync +Vsync
|
||||||
|
# 2240x1290 @ 120.00 Hz (GTF) hsync: 165.84 kHz; pclk: 517.42 MHz
|
||||||
|
Modeline "2240x1290_120.00" 517.42 2240 2432 2680 3120 1290 1291 1294 1382 -HSync +Vsync
|
||||||
|
# 2800x1290 @ 30.00 Hz (GTF) hsync: 39.39 kHz; pclk: 141.80 MHz
|
||||||
|
Modeline "2800x1290_30.00" 141.80 2800 2912 3200 3600 1290 1291 1294 1313 -HSync +Vsync
|
||||||
|
# 2800x1290 @ 60.00 Hz (GTF) hsync: 80.10 kHz; pclk: 303.74 MHz
|
||||||
|
Modeline "2800x1290_60.00" 303.74 2800 2992 3296 3792 1290 1291 1294 1335 -HSync +Vsync
|
||||||
|
# 2800x1290 @ 120.00 Hz (GTF) hsync: 165.84 kHz; pclk: 647.44 MHz
|
||||||
|
Modeline "2800x1290_120.00" 647.44 2800 3040 3352 3904 1290 1291 1294 1382 -HSync +Vsync
|
||||||
'';
|
'';
|
||||||
|
|
||||||
deviceSection = ''
|
deviceSection = ''
|
||||||
@ -101,7 +139,7 @@ in
|
|||||||
partOf = [ "graphical-session.target" ];
|
partOf = [ "graphical-session.target" ];
|
||||||
wants = [ "graphical-session.target" ];
|
wants = [ "graphical-session.target" ];
|
||||||
after = [ "graphical-session.target" ];
|
after = [ "graphical-session.target" ];
|
||||||
|
path = [ resolutionScript pkgs.xorg.xrandr pkgs.bash pkgs.xorg.libxcvt pkgs.xorg.xorgserver pkgs.gawk ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${sunshineOverride}/bin/sunshine ${configFile}";
|
ExecStart = "${sunshineOverride}/bin/sunshine ${configFile}";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
@ -115,6 +153,7 @@ in
|
|||||||
programs.steam.enable = true;
|
programs.steam.enable = true;
|
||||||
|
|
||||||
hardware = {
|
hardware = {
|
||||||
|
pulseaudio.enable = true;
|
||||||
opengl = {
|
opengl = {
|
||||||
enable = true;
|
enable = true;
|
||||||
driSupport = true;
|
driSupport = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user