Toxblh / MTMR

🌟 [My TouchBar My rules]. The Touch Bar Customisation App for your MacBook Pro
https://mtmr.app
MIT License
4.22k stars 219 forks source link

Conditional Feature #36

Open danillos opened 6 years ago

danillos commented 6 years ago

Would be good do some actions when some condition matches like to hide/show some item.

It is just some examples:

Show/Hide battery.

  { "id" : "battery_level", "type": "battery", "align": "right" },

  {
    "type" : "condition",
    "refreshInterval": 60,
    "script" : { 
      "type" : "appleScriptInline",
      "value" : "do shell script \"script that returns battery_charged when battery is charged\""
    },
    "conditions" : [
      { 
        "condition" : "=", "value" : "battery_charged", 
        "actions" : [{ "type" : "hide_item", "id" : "battery_level"}] 
      },
      { 
        "condition" : "!=", "value" : "battery_charged", 
        "actions" : [{ "type" : "show_item", "id" : "battery_level"}] 
      }
    ]
  }

Hide Player buttons when needed:

  { "id" : "previous", "type": "previous", "width": 44 },
  { "id" : "play", "type": "play", "width": 44 },
  { "id" : "next", "type": "next", "width": 44 },

  {
    "type" : "condition",
    "refreshInterval": 1,
    "script": { 
      "type" : "appleScriptInline",
      "value" : "if application \"Spotify\" is running then\rreturn \"playing\"\relse return\"\"\r"
    },
    "conditions" : [
      { 
        "condition" : "=", "value" : "playing", 
        "actions" : [
          { "type" : "show_item", "id" : "previous"},
          { "type" : "show_item", "id" : "play"},
          { "type" : "show_item", "id" : "next"}
        ] 
      },
      { 
        "condition" : "!=", "value" : "playing", 
        "actions" : [
          { "type" : "hide_item", "id" : "previous"},
          { "type" : "hide_item", "id" : "play"},
          { "type" : "hide_item", "id" : "next"}
        ] 
      },
    ]
  }
Toxblh commented 6 years ago

Hey, it’s interesting the idea, but you can already do it with appleScripts button which return empty string when the button should be hide.

I added it for future. Thanks.

HigH-HawK commented 3 years ago

I am actually looking for a similar feature. When Spotify or any other added music app is running, it should show the next/previous track buttons left/right of the current song information. The buttons should also only show, if the music app is running, otherwise they should stay hidden.

Layout:

[PrevTrack] [MusicApp _ Artist - Song] [NextTrack]