29 lines
655 B
C#
29 lines
655 B
C#
|
|
internal class ScrollLockLed
|
||
|
|
{
|
||
|
|
private readonly string[] _paths;
|
||
|
|
private bool _state;
|
||
|
|
|
||
|
|
public ScrollLockLed()
|
||
|
|
{
|
||
|
|
_paths = Directory.GetDirectories("/sys/class/leds/", "*scrolllock*");
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Set(bool on)
|
||
|
|
{
|
||
|
|
_state = on;
|
||
|
|
Write();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Refresh() => Write();
|
||
|
|
|
||
|
|
private void Write()
|
||
|
|
{
|
||
|
|
string value = _state ? "1" : "0";
|
||
|
|
foreach (var path in _paths)
|
||
|
|
{
|
||
|
|
try { File.WriteAllText(Path.Combine(path, "brightness"), value); }
|
||
|
|
catch (Exception ex) { Console.Error.WriteLine($"ScrollLockLed [{path}]: {ex.Message}"); }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|