LINUX.ORG.RU

История изменений

Исправление LINUX-ORG-RU, (текущая версия) :

Вот от сюда через rtcwake в сон уводи и поднимай автоматически назад. (Если умеет)

------------------------------------------
-------Simple auto WakeUP from sleep------
------копиригхт Цы LINUX-ORG-RU-----------
------------license WTFPL-----------------
------------------------------------------
--- заранее в /etc/rc.local шобы работало
--- chmod ugo+r  /dev/rtc0
--- chown $USER  /sys/power/state
------------------------------------------

local ctime = 
{
    year = tonumber(os.date("%Y")),
    mont = tonumber(os.date("%m")),
    days = tonumber(os.date("%d")),
    hour = tonumber(os.date("%H")),
    mins = tonumber(os.date("%M")),
    seco = tonumber(os.date("%S")),
}

chunks = {}
for substring in arg[1]:gmatch("([^:]+)") do
   table.insert(chunks, substring)
end

local wtime = 
{
    hour = tonumber(chunks[1]),
    mins = tonumber(chunks[2]),
}

if wtime.hour == nil or wtime.mins == nil then
    print("./rtcwake час:минута")
    return
end

local time = 0
local incd = 0

if ctime.hour > wtime.hour then
    incd = 1
end

time = os.time
{
    year  = ctime.year,
    month = ctime.mont,
    day   = ctime.days+incd,
    hour  = wtime.hour,
    min   = wtime.mins,
    sec   = ctime.secs
}

print("Включение в "..ctime.year.."/"..ctime.mont.."/"..ctime.days+incd.." "..wtime.hour..":"..wtime.mins)

os.execute("killall rtcwake")
os.execute("/usr/sbin/rtcwake -m mem -s "..time-os.time())
os.execute("sleep 2")
os.execute("xset dpms force on")
os.execute("nmcli networking off")
os.execute("nmcli networking on")

print("тютютю")

Использование

appname 8:30 # уйти в сон до 8:30 утра

По крону можно уводить в сон, а просыпаться будет сам. Ну или по аналогии своё написать.

Исходная версия LINUX-ORG-RU, :

Вот от сюда через rtcwake в сон уводи и поднимай автоматически назад. (Если умеет)

------------------------------------------
-------Simple auto WakeUP from sleep------
------копиригхт Цы LINUX-ORG-RU-----------
------------license WTFPL-----------------
------------------------------------------
--- заранее в /etc/rc.local шобы работало
--- chmod ugo+r  /dev/rtc0
--- chown $USER  /sys/power/state
------------------------------------------

local ctime = 
{
    year = tonumber(os.date("%Y")),
    mont = tonumber(os.date("%m")),
    days = tonumber(os.date("%d")),
    hour = tonumber(os.date("%H")),
    mins = tonumber(os.date("%M")),
    seco = tonumber(os.date("%S")),
}

chunks = {}
for substring in arg[1]:gmatch("([^:]+)") do
   table.insert(chunks, substring)
end

local wtime = 
{
    hour = tonumber(chunks[1]),
    mins = tonumber(chunks[2]),
}

if wtime.hour == nil or wtime.mins == nil then
    print("./rtcwake час:минута")
    return
end

local time = 0
local incd = 0

if ctime.hour > wtime.hour then
    incd = 1
end

time = os.time
{
    year  = ctime.year,
    month = ctime.mont,
    day   = ctime.days+incd,
    hour  = wtime.hour,
    min   = wtime.mins,
    sec   = ctime.secs
}

print("Включение в "..ctime.year.."/"..ctime.mont.."/"..ctime.days+incd.." "..wtime.hour..":"..wtime.mins)

os.execute("killall rtcwake")
os.execute("/usr/sbin/rtcwake -m mem -s "..time-os.time())
os.execute("sleep 2")
os.execute("xset dpms force on")
os.execute("nmcli networking off")
os.execute("nmcli networking on")

print("тютютю")

По крону можно уводить в сон, а просыпаться будет сам. Ну или по аналогии своё написать.