Comments (1)
Below is a heavily commented patch against 1.6.2 that fixes the issue. It's very simple, but the same patch to read the mixer volume has to be applied in 3 places, and the patch for setting mixer volume in 2 places. That code should probably be factored out to separate functions.
Let me know if you need any more input from me before importing the changes. I've added this to the FreeBSD port, which will be committed shortly pending poudriere testing.
--- libLumina/LuminaOS-FreeBSD.cpp.orig 2021-12-26 02:33:45 UTC
+++ libLumina/LuminaOS-FreeBSD.cpp
@@ -9,6 +9,8 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/sysctl.h>
+#include <sys/param.h> // __FreeBSD_version
#include <QDebug>
//can't read xbrightness settings - assume invalid until set
@@ -171,10 +173,29 @@ int LOS::audioVolume(){ //Returns: audio volume as a p
audiovolume = out;
}else{
//probe the system for the current volume (other utils could be changing it)
+ // mixer interface changed in FreeBSD 14
+ // 13 and prior: mixer -S vol outputs
+ // vol:50:50
+ // 14 and later, there is no -S flag, and vol is a fraction, not a %
+ // mixer -o vol outputs
+ // vol.volume=0.75:0.75
+ // vol.mute=0
+ // Might be better to use the mixer API instead
+#if __FreeBSD_version < 1400000
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();
+#else
+ // Produce something like vol.volume=0.26:0.26=vol.mute=0=
+ // Multiple lines are joined, separated by '='
+ QString info = LUtils::getCmdOutput("mixer -o vol").join("=").simplified();
+ if(!info.isEmpty()){
+ int L = info.section(QRegularExpression("[=:]"),1,1).toDouble() * 100.0;
+ int R = info.section(QRegularExpression("[=:]"),2,2).toDouble() * 100.0;
+#endif
+
+
if(L>R){ out = L; }
else{ out = R; }
if(out != audiovolume){
@@ -195,10 +216,27 @@ void LOS::setAudioVolume(int percent){
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();
+ // mixer interface changed in FreeBSD 14
+ // 13 and prior: mixer -S vol outputs
+ // vol:50:50
+ // 14 and later, there is no -S flag, and vol is a fraction, not a %
+ // mixer -o vol outputs
+ // vol.volume=0.75:0.75
+ // vol.mute=0
+ // Might be better to use the mixer API instead
+#if __FreeBSD_version < 1400000
+ 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();
+#else
+ // Produce something like vol.volume=0.26:0.26=vol.mute=0=
+ // Multiple lines are joined, separated by '='
+ QString info = LUtils::getCmdOutput("mixer -o vol").join("=").simplified();
+ if(!info.isEmpty()){
+ int L = info.section(QRegularExpression("[=:]"),1,1).toDouble() * 100.0;
+ int R = info.section(QRegularExpression("[=:]"),2,2).toDouble() * 100.0;
+#endif
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
@@ -207,7 +245,11 @@ void LOS::setAudioVolume(int percent){
if(L<0){L=0;}else if(L>100){L=100;}
if(R<0){R=0;}else if(R>100){R=100;}
//Run Command
+#if __FreeBSD_version < 1400000
LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R));
+#else
+ LUtils::runCmd("mixer vol="+QString::number(L/100.0)+":"+QString::number(R/100.0));
+#endif
}
}
audiovolume = percent; //save for checking later
@@ -220,15 +262,36 @@ void LOS::changeAudioVolume(int percentdiff){
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;
+ // mixer interface changed in FreeBSD 14
+ // 13 and prior: mixer -S vol outputs
+ // vol:50:50
+ // 14 and later, there is no -S flag, and vol is a fraction, not a %
+ // mixer -o vol outputs
+ // vol.volume=0.75:0.75
+ // vol.mute=0
+ // Might be better to use the mixer API instead
+#if __FreeBSD_version < 1400000
+ 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();
+#else
+ // Produce something like vol.volume=0.26:0.26=vol.mute=0=
+ // Multiple lines are joined, separated by '='
+ QString info = LUtils::getCmdOutput("mixer -o vol").join("=").simplified();
+ if(!info.isEmpty()){
+ int L = info.section(QRegularExpression("[=:]"),1,1).toDouble() * 100.0;
+ int R = info.section(QRegularExpression("[=:]"),2,2).toDouble() * 100.0;
+#endif
//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
+#if __FreeBSD_version < 1400000
LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R));
+#else
+ LUtils::runCmd("mixer vol="+QString::number(L/100.0)+":"+QString::number(R/100.0));
+#endif
}
}
}
from lumina.
Related Issues (20)
- Make config import/export util
- Lumina Config re-write
- Fix Vertical Panel issue with Task Manager Items
- Regarding commit 31d6a38 HOT 1
- Update Version String for 1.6.3
- Add Debian/Devuan Instructions provided by Koratsuki HOT 1
- Upstream NetBSD Patch HOT 1
- Windows sometimes shrunk during open (minor annoyance, low priority) HOT 6
- Terminal shortcut launches its preferences not the terminal itself HOT 1
- The settings in the "autostart" menu are not saved. HOT 1
- Cannot prompt sudo HOT 1
- Screensaver config HOT 26
- bogus fluxbox-init\ -no-slit file created under Void Linux HOT 1
- hotkeys in Lumina 1.6.2 FreeBSD
- missing transparency in Lumina 1.6.2 FreeBSD ? HOT 1
- Just a suggestion:
- external plugins for desktop & panels HOT 2
- Infinite loop in start menu HOT 4
- xcb_damage_create does not work. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lumina.