Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1027532 // Stefan's Audio Adjuster

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (6479L/33K).

1  
!7
2  
3  
cmodule AudioAdjuster > DynPrintLogAndEnabled {
4  
  transient S goodMic = "USB PnP Audio Device Analog Stereo";
5  
  transient S headphones = "Bluedio T 5th"; //"Bluedio T";
6  
  transient S internal = "HD-Audio Generic Analog Stereo";
7  
8  
  transient S defaultSink;
9  
  transient Bool haveGoodMic, haveHeadphones;
10  
  transient long lastChecked;
11  
  
12  
  start {
13  
    doEvery(10.0, r check);
14  
    dm_registerAs_direct haveHeadphones();
15  
  }
16  
17  
  void check enter {
18  
    if (!enabled) ret;
19  
    lastChecked = now();
20  
    Map<Int, S> sinks = dm_systemAudioSinkNames();
21  
    bool haveGoodMic = cicValue(sinks, goodMic);
22  
    bool haveHeadphones = cicValue(sinks, headphones);
23  
    S defaultSink = haveHeadphones ? headphones : internal;
24  
25  
    if (setFields(+defaultSink, +haveGoodMic, +haveHeadphones))
26  
      dm_pulseAudio_setDefaultSinkAndSwitchAllClients(defaultSink);
27  
  }
28  
29  
  // API
30  
31  
  WithTimestamp<Bool> haveHeadphones() {
32  
    ret withTimestamp(lastChecked, haveHeadphones);
33  
  }
34  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027532
Snippet name: Stefan's Audio Adjuster
Eternal ID of this version: #1027532/9
Text MD5: 9d059514b4847fd70feb6f2f53cc44df
Transpilation MD5: e1e91b86cafdfee431b7e7f08dfcc364
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-07 20:40:16
Source code size: 956 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 120 / 9346
Version history: 8 change(s)
Referenced in: [show references]