Skip to content

Instantly share code, notes, and snippets.

@Gevrai
Gevrai / BatteryMonitoring.swift
Created April 13, 2018 19:23
Very simple Singleton that sends a Notification whenever the state or level of the battery changed.
public class BatteryMonitoring {
public static let BatteryDidChangeNotification = Notification.Name(rawValue: "BatteryStateNotifier.BatteryDidChangeNotification")
public static let shared = BatteryMonitoring()
private init() {}
public private(set) var state : WKInterfaceDeviceBatteryState = .unknown
// State will be an int between 0 and 100 if state is not .unknown, else -1
public private(set) var level : Int = -1
dnf install kernel-devel kernel-headers gcc make dkms acpid libglvnd-glx libglvnd-opengl libglvnd-devel pkgconfig