From af6ce6ea4f6b62d0b09b0b9ae2f8d640e828802a Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 25 Oct 2016 11:54:57 -0400 Subject: Add PulseAudio support into the FreeBSD backend if a PICO session is detected. --- src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp | 77 ++++++++++++++++++----------- src-qt5/core/libLumina/LuminaXDG.cpp | 1 + src-qt5/core/libLumina/LuminaXDG.h | 3 ++ 3 files changed, 51 insertions(+), 30 deletions(-) (limited to 'src-qt5') diff --git a/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp b/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp index 2bffb5a1..b9346565 100644 --- a/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp +++ b/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp @@ -97,13 +97,14 @@ void LOS::setScreenBrightness(int percent){ //Run the command(s) bool success = false; // - try hardware setting first (TrueOS || or intel_backlight) - if( LUtils::isValidBinary("pc-sysconfig") ){ + bool remoteSession = !QString(getenv("PICO_CLIENT_LOGIN")).isEmpty(); + if( LUtils::isValidBinary("pc-sysconfig") && !remoteSession){ //Use TrueOS tool (direct sysctl control) QString ret = LUtils::getCmdOutput("pc-sysconfig", QStringList() <<"setscreenbrightness "+QString::number(percent)).join(""); success = ret.toLower().contains("success"); qDebug() << "Set hardware brightness:" << percent << success; } - if( !success && LUtils::isValidBinary("intel_backlight")){ + if( !success && LUtils::isValidBinary("intel_backlight") && !remoteSession){ //Use the intel_backlight utility (only for Intel mobo/hardware?) if(0== LUtils::runCmd("intel_backlight", QStringList() <100){percent=100;} - QString info = LUtils::getCmdOutput("mixer -S vol").join(":").simplified(); //ignores any other lines - if(!info.isEmpty()){ - int L = info.section(":",1,1).toInt(); - int R = info.section(":",2,2).toInt(); - int diff = L-R; - if((percent == L) && (L==R)){ return; } //already set to that volume - if(diff<0){ R=percent; L=percent+diff; } //R Greater - else{ L=percent; R=percent-diff; } //L Greater or equal - //Check bounds - if(L<0){L=0;}else if(L>100){L=100;} - if(R<0){R=0;}else if(R>100){R=100;} - //Run Command - audiovolume = percent; //save for checking later - LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R)); - LUtils::writeFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/.currentvolume", QStringList() << QString::number(percent), true); - } + bool remoteSession = !QString(getenv("PICO_CLIENT_LOGIN")).isEmpty(); + if(remoteSession){ + LUtils::runCmd(QString("pactl set-sink-volume @DEFAULT_SINK@ ")+QString::number(percent)+"%"); + }else{ + QString info = LUtils::getCmdOutput("mixer -S vol").join(":").simplified(); //ignores any other lines + if(!info.isEmpty()){ + int L = info.section(":",1,1).toInt(); + int R = info.section(":",2,2).toInt(); + int diff = L-R; + if((percent == L) && (L==R)){ return; } //already set to that volume + if(diff<0){ R=percent; L=percent+diff; } //R Greater + else{ L=percent; R=percent-diff; } //L Greater or equal + //Check bounds + if(L<0){L=0;}else if(L>100){L=100;} + if(R<0){R=0;}else if(R>100){R=100;} + //Run Command + LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R)); + } + } + audiovolume = percent; //save for checking later + LUtils::writeFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/.currentvolume", QStringList() << QString::number(percent), true); } //Change the current volume a set amount (+ or -) void LOS::changeAudioVolume(int percentdiff){ - QString info = LUtils::getCmdOutput("mixer -S vol").join(":").simplified(); //ignores any other lines - if(!info.isEmpty()){ - int L = info.section(":",1,1).toInt() + percentdiff; - int R = info.section(":",2,2).toInt() + percentdiff; - //Check bounds - if(L<0){L=0;}else if(L>100){L=100;} - if(R<0){R=0;}else if(R>100){R=100;} - //Run Command - LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R)); + bool remoteSession = !QString(getenv("PICO_CLIENT_LOGIN")).isEmpty(); + if(remoteSession){ + LUtils::runCmd(QString("pactl set-sink-volume @DEFAULT_SINK@ ")+((percentdiff>0)?"+" : "") + QString::number(percentdiff)+"%"); + }else{ + QString info = LUtils::getCmdOutput("mixer -S vol").join(":").simplified(); //ignores any other lines + if(!info.isEmpty()){ + int L = info.section(":",1,1).toInt() + percentdiff; + int R = info.section(":",2,2).toInt() + percentdiff; + //Check bounds + if(L<0){L=0;}else if(L>100){L=100;} + if(R<0){R=0;}else if(R>100){R=100;} + //Run Command + LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R)); + } } } diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index 8ae77ea6..b0d2edd9 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -22,6 +22,7 @@ XDGDesktop::XDGDesktop(QString file, QObject *parent) : QObject(parent){ isHidden=false; useTerminal=false; startupNotify=false; + useVGL = false; type = XDGDesktop::BAD; filePath = file; exec = tryexec = ""; // just to make sure this is initialized diff --git a/src-qt5/core/libLumina/LuminaXDG.h b/src-qt5/core/libLumina/LuminaXDG.h index acb688ff..1c86cedb 100644 --- a/src-qt5/core/libLumina/LuminaXDG.h +++ b/src-qt5/core/libLumina/LuminaXDG.h @@ -64,6 +64,9 @@ public: QStringList actionList, mimeList, catList, keyList; bool useTerminal, startupNotify; QList actions; + //Type 1 Extensions for Lumina (Optional) + bool useVGL; //X-VGL + //Type 2 (LINK) variables QString url; -- cgit