forked from vicious-widgets/vicious
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Samuel
committed
Sep 10, 2020
1 parent
f452b57
commit bdf4583
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- template for asynchronous widet types | ||
-- Copyright (C) 2019 Nguyễn Gia Phong <[email protected]> | ||
-- | ||
-- This file is part of Vicious. | ||
-- | ||
-- Vicious is free software: you can redistribute it and/or modify | ||
-- it under the terms of the GNU General Public License as | ||
-- published by the Free Software Foundation, either version 2 of the | ||
-- License, or (at your option) any later version. | ||
-- | ||
-- Vicious is distributed in the hope that it will be useful, | ||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
-- GNU General Public License for more details. | ||
-- | ||
-- You should have received a copy of the GNU General Public License | ||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
local helpers = require("vicious.helpers") | ||
local spawn = require("vicious.spawn") | ||
local gears = require("gears") | ||
|
||
local brightness_linux = {} | ||
|
||
function brightness_linux.async(format, warg, callback) | ||
local cmd = "brightnessctl -m" | ||
|
||
local function parse(response) | ||
-- extract percentage which incldues '%' at the end | ||
response = gears.string.split(response, ',')[4] | ||
-- remove '%' at the end | ||
response = response:sub(1, response:len()-1) | ||
return {response} | ||
end | ||
|
||
spawn.easy_async(cmd, function(stdout) callback(parse(stdout)) end) | ||
end | ||
|
||
return helpers.setasyncall(brightness_linux) |