-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
8 changed files
with
142 additions
and
8 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
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
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,21 @@ | ||
function pulse() | ||
local pulse_vol = io.popen('pamixer --get-volume') | ||
pulse_vol:setvbuf('no') | ||
repeat | ||
cur_vol = pulse_vol:read("*l") | ||
until | ||
nil == pulse_vol:read("*l") | ||
pulse_vol:close() | ||
return cur_vol | ||
end | ||
|
||
widget = { | ||
plugin = 'alsa', | ||
cb = function(t) | ||
if t.mute then | ||
return {full_text = '[mute]', color = '#e03838'} | ||
else | ||
return {full_text = pulse(), color = '#718ba6'} | ||
end | ||
end, | ||
} |
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,28 @@ | ||
mem_uev = assert(io.open('/proc/meminfo', 'r')) | ||
mem_uev:setvbuf('no') | ||
|
||
function get_mem_seg() | ||
local result = '[-?-]' | ||
mem_uev:seek('set', 0) | ||
for line in mem_uev:lines() do | ||
local key, value, um = string.match(line, '(.*): +(.*) +(.*)') | ||
if key == 'MemFree' then | ||
value = tonumber(value) | ||
if um == 'kB' then | ||
value = value / 1024.0 / 1024.0 | ||
um = 'GiB' | ||
end | ||
result = string.format('[%3.2f %s]', value, um) | ||
break | ||
end | ||
end | ||
return {full_text = result, color = '#af8ec3'} | ||
end | ||
|
||
widget = { | ||
plugin = 'timer', | ||
opts = {period = 2}, | ||
cb = function(t) | ||
return {get_mem_seg()} | ||
end, | ||
} |
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,40 @@ | ||
bat_uev = io.open('/sys/class/power_supply/BAT0/uevent', 'r') | ||
if bat_uev then | ||
bat_uev:setvbuf('no') | ||
end | ||
|
||
function get_bat_seg() | ||
if not bat_uev then | ||
return {full_text = '[-?-]'} | ||
end | ||
bat_uev:seek('set', 0) -- yes, seeking on sysfs files is OK | ||
local status, capa | ||
for line in bat_uev:lines() do | ||
local key, value = string.match(line, '(.-)=(.*)') | ||
if key == 'POWER_SUPPLY_STATUS' then | ||
status = value | ||
elseif key == 'POWER_SUPPLY_CAPACITY' then | ||
capa = tonumber(value) | ||
end | ||
end | ||
if status == 'Unknown' or status == 'Full' then | ||
return nil | ||
end | ||
local sym, color = '?', '#dcdcdc' | ||
if status == 'Discharging' then | ||
sym = '↓' | ||
color = '#dca3a3' | ||
elseif status == 'Charging' then | ||
sym = '↑' | ||
color = '#60b48a' | ||
end | ||
return {full_text = string.format('[%3d%%%s]', capa, sym), color = color} | ||
end | ||
|
||
widget = { | ||
plugin = 'timer', | ||
opts = {period = 2}, | ||
cb = function(t) | ||
return {{full_text = os.date('[%H:%M]'), color = '#dc8cc3'}, get_bat_seg()} | ||
end, | ||
} |
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,32 @@ | ||
-- A Rube Goldberg machine widget that updates itself on click. | ||
|
||
fifo_path = assert(os.getenv('HOME')) .. '/.luastatus-timer-fifo' | ||
|
||
assert(0 == luastatus.rc{ | ||
'/bin/sh', | ||
'-c', | ||
'set -e; rm -f -- "$1"; mkfifo -m600 -- "$1"', | ||
'', -- this is $0 | ||
fifo_path, -- and this is $1 | ||
}) | ||
|
||
widget = { | ||
plugin = 'timer', | ||
opts = { | ||
fifo = fifo_path, | ||
period = 2.0, | ||
}, | ||
cb = function(t) | ||
if t == 'fifo' then | ||
return {full_text = 'Thanks!'} | ||
else | ||
return {full_text = 'Click me'} | ||
end | ||
end, | ||
event = function(t) | ||
-- opening the FIFO for writing here may, in some rare cases, block (and doing this from | ||
-- this process would lead to a deadlock), so we spawn another process to do it and do not | ||
-- wait for its termination (which would also lead to a deadlock). | ||
luastatus.spawn{'touch', '--', fifo_path} | ||
end, | ||
} |
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,12 @@ | ||
widget = { | ||
plugin = 'xkb', | ||
cb = function(t) | ||
if t.name == 'us' then | ||
return {full_text = '[En]', color = '#9c9c9c'} | ||
elseif t.name == 'ru(winkeys)' then | ||
return {full_text = '[Ru]', color = '#eab93d'} | ||
else | ||
return {full_text = '[' .. t.id .. ']'} | ||
end | ||
end, | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /bin/bash | ||
mkdir -p .config | ||
cp -rv $HOME/.{bash_profile,bashrc,saf-scrypt,vimrc,Xresources,zprofile,zshrc} . | ||
cp -rv $HOME/.config/{compton.conf,fontconfig,htop,i3} .config/ | ||
cp -v $HOME/.{bash_profile,bashrc,saf-scrypt,vimrc,Xresources,zprofile,zshrc} . | ||
cp -rv $HOME/.config/{luastatus,compton.conf,fontconfig,htop,i3} .config/ |