<commit_before>//
//  MenuBarLyrics.swift
//  LyricsX
//
//  Created by 邓翔 on 2017/2/8.
//  Copyright © 2017年 ddddxxx. All rights reserved.
//

import Cocoa

class MenuBarLyrics {
    
    var enabled = UserDefaults.standard.bool(forKey: MenuBarLyricsEnabled)
    
    var statusItem: NSStatusItem?
    
    init() {
        NotificationCenter.default.addObserver(forName: .lyricsShouldDisplay, object: nil, queue: .main) { n in
            guard self.enabled,
                let lrc = n.userInfo?["lrc"] as? String, lrc != ""else {
                self.statusItem = nil
                return
            }
            
            self.statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
            self.statusItem?.highlightMode = false
            self.statusItem?.button?.title = lrc
        }
        
        NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: .main) { n in
            self.enabled = UserDefaults.standard.bool(forKey: MenuBarLyricsEnabled)
        }
    }
    
}<commit_msg>Bugfix: Menu bar lyrics do not hide when iTunes paused<commit_after>//
//  MenuBarLyrics.swift
//  LyricsX
//
//  Created by 邓翔 on 2017/2/8.
//  Copyright © 2017年 ddddxxx. All rights reserved.
//

import Cocoa

class MenuBarLyrics {
    
    var enabled = UserDefaults.standard.bool(forKey: MenuBarLyricsEnabled)
    
    var statusItem: NSStatusItem?
    
    init() {
        NotificationCenter.default.addObserver(forName: .lyricsShouldDisplay, object: nil, queue: .main) { n in
            guard self.enabled,
                let lrc = n.userInfo?["lrc"] as? String, lrc != ""else {
                self.statusItem = nil
                return
            }
            
            self.statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
            self.statusItem?.highlightMode = false
            self.statusItem?.button?.title = lrc
        }
        
        NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: .main) { n in
            self.enabled = UserDefaults.standard.bool(forKey: MenuBarLyricsEnabled)
            if !self.enabled {
                self.statusItem = nil
            }
        }
    }
    
}
{'fraction_non_alphanumeric': 0.097911227154047, 'fraction_numerical': 0.008703220191470844, 'mean_word_length': 2.0450331125827814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6408319', 'n_tokens_mistral': 703, 'n_tokens_neox': 657, 'n_words': 143}