macOS Control Center - MCC

@EvinHarris can you test this, let me know if its fixed

macOS-Control-Center-v0_3_1.bttpresetzip (215.7 KB)

@Andreas_Hegenberg is this same when btt launches shell/applescripts? difference is too much, im trying to speedup start time of mcc

Script Benchmark

try

set t to (time string of ( current date ))

set [hoursInNumber, minutesInNumber, secondInNumber] to the words of t

set startingtime to ((hoursInNumber * 3600) + (minutesInNumber * 60) + secondInNumber)

repeat 100 times

tell application "System Events" to set v to value of property list item 1 of property list file "/Library/Preferences/com.apple.Bluetooth.plist"

end repeat

set t to (time string of ( current date ))

set [hoursInNumber, minutesInNumber, secondInNumber] to the words of t

set endtime to ((hoursInNumber * 3600) + (minutesInNumber * 60) + secondInNumber)

return endtime - startingtime

end try

--do shell script "defaults read /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState"

--43 seconds to complete

--tell application "System Events" to set v to value of property list item 1 of property list file "/Library/Preferences/com.apple.Bluetooth.plist"

--1 seconds to complete

apple script is always slow, use shell scripts or java script whenever possible.

Hey!

This is nice. But how do I activate it?

@Andreas_Hegenberg thanks Andreas for tip

i try new callbtt function for next release but artist section didnt work. im not sure but i guess problem is code giving error when i try to split artist info otherwise it was worked for itunes and spotify (has song and artist info). here is code

Working code

async function bttRequest(requestPath) {
const response = await fetch(requestPath);
const responseText = await response.text();
return responseText;
}

async function NowPlaying() {

let song = await bttRequest(
"bttweb://get_string_variable/?variableName=BTTNowPlayingInfoTitle"
);

let artist = await bttRequest(
"bttweb://get_string_variable/?variableName=BTTNowPlayingInfoArtist"
);

let playingstatus = await bttRequest(
"bttweb://get_number_variable/?variableName=BTTCurrentlyPlaying"
);
      
if (playingstatus == 1) 
    { 
    playpause.style.display = "none"
    playplay.style.display = "inline-block"
    }
else
    { 
    playpause.style.display = "inline-block"
    playplay.style.display = "none"
    }
      
if (song !== '' & artist !== '') 
    {
    mccnpt.innerHTML = song;
    mccnpa.innerHTML = artist;
    }
else if(song == '' & artist == '')
    {
    mccnpt.innerHTML = "macOS";
    mccnpa.innerHTML = 'Control Center';
    }
else if(song == '' & artist !== '')
    {
    mccnpt.innerHTML = artist;
    mccnpa.innerHTML = '♫';
    }

else {
    
let npchecksp = song.split(/ - | by | on |[|]/)[1];

if(npchecksp == null){
    mccnpt.innerHTML = song;
    mccnpa.innerHTML = '♫';
}
else if (npchecksp == "YouTube"){
    mccnpt.innerHTML = song.split("- YouTub")[0];
    mccnpa.innerHTML = 'YouTube';
    }
else if (npchecksp == "Vimeo"){
    mccnpt.innerHTML = song.split(" on Vime")[0];
    mccnpa.innerHTML = 'Vimeo';
    }
else if (npchecksp == "Spotify"){
    mccnpt.innerHTML = song.split(" on Spoti")[0];
    mccnpa.innerHTML = 'Spotify Web';
    }
else if (song.split(" - ")[2] == "Deezer"){
    mccnpt.innerHTML = song.split(" - ")[0];
    mccnpa.innerHTML = song.split(" - ")[1];
    }
else if (song.charAt(0) == "▶"){
    mccnpt.innerHTML = song.split("▶")[1].split(/ - | by |[|]/)[0];
    mccnpa.innerHTML = song.split("▶")[1].split(/ - | by |[|]/)[1];
    }
else {
    mccnpt.innerHTML = npchecksp;
    mccnpa.innerHTML = song.split(" - ")[0];
    }
    }
      
function isElementOverflowing(element) {
    var overflowX = element.offsetWidth < element.scrollWidth;
    return overflowX;
    }

function wrapContentsInMarquee(element) {
    var marquee = element.firstElementChild.classList.add('marquee'),
    contents = element.innerText;
    marquee.innerText = contents;
    element.innerHTML = '';
    }

var elements = document.getElementsByClassName("overflow");
    for (var i = 0; i < elements.length; i++) {
      if (isElementOverflowing(elements[i])) {
        wrapContentsInMarquee(elements[i]);
      }
    }
    }
Didn't working

async function NowPlaying() {

let song = await callBTT('get_string_variable', {variableName: 'BTTNowPlayingInfoTitle'})

let artist = await callBTT('get_string_variable', {variableName: 'BTTNowPlayingInfoArtist'})

let playingstatus = await callBTT('get_number_variable', {variableName: 'BTTCurrentlyPlaying'})

if (playingstatus == 1) 
    { 
    playpause.style.display = "none"
    playplay.style.display = "inline-block"
    }
else
    { 
    playpause.style.display = "inline-block"
    playplay.style.display = "none"
    }
      
if (song !== '' & artist !== '') 
    {
    mccnpt.innerHTML = song;
    mccnpa.innerHTML = artist;
    }
else if(song == '' & artist == '')
    {
    mccnpt.innerHTML = "macOS";
    mccnpa.innerHTML = 'Control Center';
    }
else if(song == '' & artist !== '')
    {
    mccnpt.innerHTML = artist;
    mccnpa.innerHTML = '♫';
    }

else {
    
let npchecksp = song.split(/ - | by | on |[|]/)[1];

if(npchecksp == null){
    mccnpt.innerHTML = song;
    mccnpa.innerHTML = '♫';
}
else if (npchecksp == "YouTube"){
    mccnpt.innerHTML = song.split("- YouTub")[0];
    mccnpa.innerHTML = 'YouTube';
    }
else if (npchecksp == "Vimeo"){
    mccnpt.innerHTML = song.split(" on Vime")[0];
    mccnpa.innerHTML = 'Vimeo';
    }
else if (npchecksp == "Spotify"){
    mccnpt.innerHTML = song.split(" on Spoti")[0];
    mccnpa.innerHTML = 'Spotify Web';
    }
else if (song.split(" - ")[2] == "Deezer"){
    mccnpt.innerHTML = song.split(" - ")[0];
    mccnpa.innerHTML = song.split(" - ")[1];
    }
else if (song.charAt(0) == "▶"){
    mccnpt.innerHTML = song.split("▶")[1].split(/ - | by |[|]/)[0];
    mccnpa.innerHTML = song.split("▶")[1].split(/ - | by |[|]/)[1];
    }
else {
    mccnpt.innerHTML = npchecksp;
    mccnpa.innerHTML = song.split(" - ")[0];
    }
    }
      
function isElementOverflowing(element) {
    var overflowX = element.offsetWidth < element.scrollWidth;
    return overflowX;
    }

function wrapContentsInMarquee(element) {
    var marquee = element.firstElementChild.classList.add('marquee'),
    contents = element.innerText;
    marquee.innerText = contents;
    element.innerHTML = '';
    }

var elements = document.getElementsByClassName("overflow");
    for (var i = 0; i < elements.length; i++) {
      if (isElementOverflowing(elements[i])) {
        wrapContentsInMarquee(elements[i]);
      }
    }
    }

@microfx thanks

How to Activate

  • Double click on menubar
  • fn+1 keyboard shortcut

from first post :wink:

1 Like

Updated first post with 0.4 release

Changelog

  • New - added appereance settings with 5 options. Dark Grey, Light Grey, Contrast Orange, Night Lake and New Wave. Choose your favorite color palette from Control Center Settings Pane




  • New - Added transparency settings to Control Center Settings Pane. You can disable background blur now

  • New - Added menubar media controls. You can control your media from menubar with gestures.


    Enable or disable them from Control Center Settings Pane. Customize them from Better Touch Tool

  • New - added new icons to preset folder and toggle / function pages in settings.

  • Minor Changes

This is brilliant idea! But i dont know why it doesnt work. Last stable BTT, last Catalina

is this fresh install or did you update this. can you try uninstall mcc preset (double check from triggerlist and remove all mcc related triggers if you have) and install again.please let me know result. it looks like control center cant get values from btt, i will update my btt and check again, i will release a new version soon also still you can try previous versions

Yes, always fresh install. Other versions doesnt work too. I guess i need change some settings in BTT, any ideas?

i think i found the problem, open BTT settings and go Scripting BTT tab, enable "Allow external BetterTouchTool scripting", please let me know if its fixed

Yes. It's pefrectly working. Thank you!

@yw4z thank for the great work. Is there a chance to add a feature like changing automatically MCC theme when the OS dark/light preference change ?

@derand thanks for your comment, it looks like thats possible with shell scripting , i will add this to future plans

Updated first post with 0.5 release

Changelog

  • New - Toggles; Color Picker, Hey Siri, Airplay Mirroring, Calculator, Truetone Toggle, Time Machine Backup, Bluetooth Device Toggle

     Color Picker; Starts native macOS color picker. Pick or set a color then click "OK". it copies color code (HEX) to clipboard

     Hey Siri; Starts Siri, Right click opens Siri settings

     Airplay Mirroring; Toggles Airplay Mirroring, Right click opens display settings

     Calculator; Starts Calculator

     Truetone Toggle; Icon is visible if supported, Right click opens display settings

     Time Machine Backup; Normal click starts time machine backup, Right click opens time machine

     Bluetooth Device Toggle; Connect/Disconnect bluetooth device (Configure which device from BTT), Right click opens bluetooth settings

     Do Not Disturb; Disable / Enable macOS notifications, Right click opens notification settings

  • New - Functions; Share with Messages, Share with Mail, Share with Notes

  • New - Scroll / Swipe on toggles / functions sections to see more icons

  • New - Rearrange toggles / functions from Control Center settings

  • New - Another way to open Control Center. Swipe top edge to bottom edge on Trackpad opens Control Center (swipe slowly). You can enable/disable from Control Center settings

  • New - Hover animation on sliders

  • Improvement - Battery button; shows battery percentage, time remaining, battery health and cycles

  • Improvement - Reduced ram usage, almost half of previous release

  • Improvement - All MCC triggers moved to html file (except Screenshot, Screen record, BetterTouchTool Preset Toggle & Bluetooth Device Toggle). BTT trigger list cleaner now. All used applescripts moved to BTT_PRESET_PATH/MCC/as/ and moved all trigger/functions to bottom side of html file. its easier to customize

  • Improvement - BetterTouchTool Preset Toggle and Bluetooth Device toggle displays a dialog if its not configured

  • Improvement - User Toggles / Functions reveals related script file in finder if its not customized

  • Improvement - Share with Airdrop. now works with Safari, Finder, Photos, Notes & Maps apps

  • Improvement - Dark Mode Toggle right click opens dark mode settings

  • Improvement - BetterTouchTool Preset Toggle right click restarts BetterTouchTool, MCC shows a dialog if its not customized

  • Added links for free alternatives to these apps; MOS Scrolling App & Amphetamine Sleep Disabler App

  • Future Plans Updated

Any idea how to fix the battery text offset? This is a fresh install on Catalina.

@joker

Can you replace this MCC.html file with existing one in preset folder, Open Control Center settings with right clicking Apple logo on Control Center then click "Open Preset Folder" to show preset folder

MCC.html (58.3 KB)

Let me know if its fixed,

This file also fixes;

  • Clicking bluetooth toggle closes Control Center
  • Control Center not opens with long song titles ( replaced marquee script with simpler one)

i will upload 0.6 release after some testing

1 Like

That fixed it. Thank you!

Screen Shot 2020-05-05 at 5.42.39 PM

Hello!
Replacing MCC.html file successfully fixed battery text offset problem, but the blur layer offset still exists with either v0.3.1 or v0.5. Please take a look, thanks! :blush:

@Sprity_Tang

hi, this bug reported on previous comments, i added some changes but looks like its not fixed,

can you replace this one then please let me know if its fixed

MCC.html (58.3 KB)

thanks

Hi,
No, sadly it still looks the same way as previous one. :thinking: