1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-09 16:48:38 +00:00

YandexWeatherBarItem: fixes in parsing (#454)

This commit is contained in:
Vladimir Tolstikov 2023-02-28 21:27:06 +04:00 committed by GitHub
parent 5e609c2446
commit d39b4c0c31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 31 deletions

View File

@ -13,13 +13,15 @@ class HapticFeedback {
// Here we have list of possible IDs for Haptic Generator Device. They are not constant
// To find deviceID, you will need IORegistryExplorer app from Additional Tools for Xcode dmg
// which you can download from https://developer.apple.com/download/more/?=Additional%20Tools
// Open IORegistryExplorer app, search for AppleMultitouchDevice and get "Multitouch ID"
// Open IORegistryExplorer app, search for "AppleMultitouchDevice" and get "Multitouch ID"
// or "AppleMultitouchTrackpadHIDEventDriver" and get "mt-device-id"
// There should be programmatic way to get it but I can't find, no docs for macOS :(
private let possibleDeviceIDs: [UInt64] = [
0x200_0000_0100_0000, // MacBook Pro 2016/2017
0x300_0000_8050_0000, // MacBook Pro 2019/2018
0x200_0000_0000_0024, // MacBook Pro (13-inch, M1, 2020)
0x200_0000_0000_0023 // MacBook Pro M1 13-Inch 2020 with 1tb
// 0x300000080500000,
]
// you can get a plist `otool -s __TEXT __tpad_act_plist /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/Current/MultitouchSupport|tail -n +3|awk -F'\t' '{print $2}'|xxd -r -p`

View File

@ -13,35 +13,21 @@ class YandexWeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate
private let activity: NSBackgroundActivityScheduler
private let unitsStr = "°C"
private let iconsSource = [
"Ясно": "☀️",
"Малооблачно": "🌤",
"Облачно с прояснениями": "⛅️",
"Пасмурно": "☁️",
"Небольшой дождь": "🌦",
"Морось": "💦",
"Дождь": "🌧",
"Ливень": "",
"Гроза": "🌩",
"Дождь с грозой": "",
"Дождь со снегом": "☔️",
"Небольшой снег": "❄️",
"Снег": "🌨",
"Туман": "🌫",
"Clear": "☀️",
"Mostly clear": "🌤",
"Partly cloudy": "⛅️",
"Overcast": "☁️",
"Light rain": "🌦",
"Drizzle": "💦",
"Rain": "🌧",
"Heavy rain": "",
"Storm": "🌩",
"Thunderstorm with rain": "",
"Sleet": "☔️",
"Light snow": "❄️",
"Snow": "🌨",
"Fog": "🌫"
"clear": "☀️",
"mostly-clear": "🌤",
"partly-cloudy": "⛅️",
"overcast": "☁️",
"cloudy": "☁️",
"light-rain": "🌦",
"drizzle": "💦",
"rain": "🌧",
"heavy-rain": "",
"storm": "🌩",
"thunderstorm-with-rain": "",
"sleet": "☔️",
"light-snow": "❄️",
"snow": "🌨",
"fog": "🌫"
]
private var location: CLLocation!
private var prevLocation: CLLocation!
@ -107,7 +93,7 @@ class YandexWeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate
temperature = matches.first?.item(at: 1)
var icon: String?
matches = response.matchingStrings(regex: "link__condition.*?>(.*?)<")
matches = response.matchingStrings(regex: "\"condition\":\"(.*?)\"")
icon = matches.first?.item(at: 1)
if let _ = icon, let test = self.iconsSource[icon!] {
icon = test