You are not logged in.
This seems to work:
w | awk '/ up /{gsub(/,$/,"",$3);print $3}'
EDIT: not sure about the "days" thing though as my laptop is never on that long
Last edited by Head_on_a_Stick (2016-12-31 16:44:05)
Offline
$ last -x reboot -1
reboot system boot 4.4.0-21-generic Sat Dec 31 10:39 still running
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
This seems to work:
w | awk '/ up /{gsub(/,$/,"",$3);print $3}'
OH SURE! Now you show us! You CLI Ninja you! You've got more Martian in that line than I know.
Also I totally forgot about searching for an 'awk' method and spent my time on sed and grep.
AND I never knew there was a "w" command. :8
That's pretty damn slick! Thanks
... but looking at it I like the "padded 0" for the hours. it matches the 24HR time I use.
reboot system boot 4.4.0-21-generic Sat Dec 31 10:39 still running
SAY WHAT? Mine is 'still running' as well but still shows:
$ last -x reboot | head -1
reboot system boot 3.16.0-4-amd64 Sat Dec 31 09:10 - 13:44 (04:34)
don't know what to say damo.
Will be interesting to see what HoaS's little line shows for uptimes longer than a day or six
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
^ Well I'm not running a vanilla BL on this machine, so there is likely to be differences. I posted mainly to demonstrate that the command may not transfer to other setups.
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
So because of HoaS's "w" command I went looking for a "list of commands"
OH MY: compgen
add a "| sort" and it looks better!
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
^ Well I'm not running a vanilla BL on this machine, so there is likely to be differences. I posted mainly to demonstrate that the command may not transfer to other setups.
Neither am I. Mine is a highly customized "BL Alpha" release.
BUT it's good to know the command isn't 'universal' and now I can't find where I actually found that.
HoaS's little line is looking better. Does that work for you?
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
$ w | awk '/ up /{gsub(/,$/,"",$3);print $3}'
7:55
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
Good, I've adopted that in my "test.conky" I'll miss the 0 but if it works, it works.
Does "who" give you your boot-up time?
31 Dec 16 @ 15:50:26 ~
$ who -b
system boot 2016-12-31 09:10
31 Dec 16 @ 15:50:54 ~
$ who -b | cut -c 23-
2016-12-31 09:10
31 Dec 16 @ 15:50:59 ~
$ who -b | cut -d' ' -f14
09:10
Last edited by Sector11 (2016-12-31 19:05:28)
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
^ Yes
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
Good - now you're cookin
And remember on New Years Eve don't conky and drink wine at the same time
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Happy New Year.
I copied the 'Do I need a Jacket' Rainmeter skin over to conky. I don't know if this has already been done before.
I have dropped the original creator a mail asking for permission to use their code, but I haven't got a reply yet. Although it should be fine given that rainmeter is gpl.
The rainmeter skin was in lua, so only minor changes were required.
Testers are welcome.
dinaj.lua
--[[
dinaj.lua
lua script for Do I need a Jacket Conky
easysid
Thursday, 05 January 2017 13:22 IST
Based on the dinaj Rainmeter skin by FlyingHyrax
Credits:
* FlyingHyrax (http://flyinghyrax.deviantart.com)
* https://doineedajacket.com/
* mrpeachy, for the out() function
--]]
require 'cairo'
-- replace with your accuweather url. Be sure to use the current-weather url
local url = "http://www.accuweather.com/en/in/delhi/202396/current-weather/202396"
-- update frequency (in conky cycles)
local update_time = 600
-- testing flag
local testing = 1
-- settings table. customize as per your liking
-- default ranges are in degrees Celcius
local t = {
-- temperature settings
JacketThreshold = 15, -- degrees Celcius
CoatThreshold = 3,
unit = "C",
-- text settings
font = "sans", -- font face for the text
color = {0xf0f0f0, 1}, -- {hex, alpha}
-- line 1 - Do you need a jacket
l1 = {
font_size = 35, -- font size
x = 10, -- x position of text
y = 30
},
-- line 2 - outside conditions
l2 = {
font_size = 23, -- font size
x = 20, -- x position of text
y = 70
},
} -- end settings table
--[[ You should not need to edit below this line ]]
local Constants = {
RANGE_MIN = -30,
RANGE_MAX = 50,
ADJECTIVES = {
"damn cold",
"darn cold",
"bone chilling",
"glacial",
"frigid",
"freezing",
"frosty",
"pretty cold",
"chilly",
"brisk",
"cool",
"quite temperate",
"rather mild",
"pretty nice",
"positively balmy",
"extra warm",
"kinda hot",
"roasting",
"scorching",
"oven-like",
"like your hair is on FIRE",
}
}
local start = 1
-- main function.
function conky_main()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display,
conky_window.drawable, conky_window.visual,
conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates = tonumber(conky_parse('${updates}'))
local timer = updates % update_time
-- time the fetch data
if timer == 0 or start == 1 then
start = nil
data = fetchData()
end
doINeedAJacket(data)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end
function fetchData()
-- print("In the fetchData function")
-- don't trust the user. Fix the url
url = string.gsub(url, "weather%-forecast", "current-weather")
local f = io.popen(string.format("curl --max-time 60 '%s'", url))
local data = f:read("*a")
f:close()
return data
end
function doINeedAJacket(data)
local b = nil
b = string.match(data, '"small.temp"><em>RealFeel.*</em>.-</span>')
if b then
local temp = tonumber(string.match(b, 'em>%s(-?%d+).-span>'))
-- print(b,temp)
local s1 = getMainString(temp)
local s2 = getSubString(temp, t.unit)
out({x=t.l1.x, y=t.l1.y, fs=t.l1.font_size, f=t.font, c=t.color, txt=s1})
out({x=t.l2.x, y=t.l2.y, fs=t.l2.font_size, f=t.font, c=t.color, txt=s2})
if testing then
local s = string.format("Current temperature: %d °%s", temp, t.unit)
out({txt=s, x=30, y=200, fs=18})
end
else
out({x=100,y=100,txt="Debug flag. There seems to be a problem"})
end
end
-- Keeps a value inside the given range
function clamp(value, min, max)
local clamped = value
if value < min then
clamped = min
elseif value > max then
clamped = max
end
return clamped
end
-- Adjusts a value and its defined range if the value is negative
function normalize(value, min, max)
local excess = min < 0 and 0 - min or 0
return value + excess, min + excess, max + excess
end
-- Return a value as a percentage of its range
function percentOfRange(value, min, max)
-- normalize
local value, min, max = normalize(value, min, max)
-- maths
local percent = (value / max - min)
-- clamping
return clamp(percent, 0.0, 1.0)
end
-- Convert a number from celsius to fahrenheit
function c2f(celsius)
return (((celsius * 9) / 5) + 32)
end
-- Return a descriptor for the given temperature and scale
function getTempWord(temp, unit)
-- convert our range bounds to fahrenheit if necessary
local unit = unit or 'C'
local tmin = unit == 'C' and Constants.RANGE_MIN or c2f(Constants.RANGE_MIN)
local tmax = unit == 'C' and Constants.RANGE_MAX or c2f(Constants.RANGE_MAX)
-- percentage of our temperature range
local tempPer = percentOfRange(temp, tmin, tmax)
-- index in array of descriptors, based on that percentage
local index = math.ceil(#Constants.ADJECTIVES * tempPer)
-- if temp is 0% of our range, index will be off by one
if index < 1 then index = 1 end
-- return that word
return Constants.ADJECTIVES[index]
end
-- Answer the question
function getMainString(temp)
local negation = (temp > t.JacketThreshold) and " don't" or ""
local outerwear = (temp < t.CoatThreshold) and "coat" or "jacket"
return string.format("You%s need a %s", negation, outerwear)
end
-- Return the appropriate secondary string
function getSubString(temp, unit)
return string.format("It's %s outside", getTempWord(temp, unit))
end
function out(txj)
-- Taken from mrpeachy's wun.lua
-- args: c,a,f,fs,face,x,y,txt,hj,vj,ro,sxo,syo,sfs,sface,sc,sa
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
local function justify(jtxt,x,hj,y,vj,f,face,fs)
if face=="normal" then
face={f,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL}
elseif face=="bold" then
face={f,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD}
elseif face=="italic" then
face={f,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL}
elseif face=="bolditalic" then
face={f,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD}
else
print ('face not set correctly - "normal","bold","italic","bolditalic"')
end
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_text_extents(cr,jtxt,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
local tx=x
local ty=y
--set horizontal alignment - l, c, r
if hj=="l" then
x=x-bx
elseif hj=="c" then
x=x-((wx-bx)/2)-bx
elseif hj=="r" then
x=x-wx
else
print ("hj not set correctly - l, c, r")
end
--vj. n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
y=y
elseif vj=="nb" then
y=y-by
elseif vj=="m" then
y=y+((hy-by)/2)
elseif vj=="mb" then
y=y+(hy/2)-by
elseif vj=="t" then
y=y+hy-by
else
print ("vj not set correctly - n, nb, m, mb, t")
end
return face,fs,x,y,rad,rad2,tx,ty
end--justify local function #################
--set variables
local c=txj.c or {0xffffff, 1}
local a=txj.a or 1
local f=txj.f or "monospace"
local fs=txj.fs or 12
local x=txj.x or 100
local y=txj.y or 100
local txt=txj.txt or "text"
local hj=txj.hj or "l"
local vj=txj.vj or "n"
local face=txj.face or "normal"
--print text ################################
local face,fs,x,y=justify(txt,x,hj,y,vj,f,face,fs)
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_move_to (cr,x,y)
cairo_set_source_rgba (cr,rgba_to_r_g_b_a(c))
cairo_show_text (cr,txt)
cairo_stroke (cr)
return nx
end--function ou
function rgba_to_r_g_b_a(tcolor)
local color,alpha=tcolor[1],tcolor[2]
return ((color / 0x10000) % 0x100) / 255.,
((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end --end rgba
-- Log the descriptor which is returned for various temperatures
local function test()
for i = -30, 55, 4 do
-- print(string.format("t=%d, s=%s", i, getTempWord(i)))
print(string.format("\nt=%d:\n%s\n%s\n", i,
getMainString(i), getSubString(i, t.unit)))
end
end
Edit: 6-Jan-2017 : Fixed the temperature regex.
Last edited by easysid (2017-01-06 05:49:36)
Offline
url = "http://www.accuweather.com/de/de/lichtenstein/09350/weather-forecast/171261"
url = "http://www.accuweather.com/en/de/lichtenstein/09350/weather-forecast/171261"
Even if the line is ... /en/de/..., no function.
With your url it is ok.
in conky
...
# — Lua Load — #
lua_load /media/DATEN/francescoPC/Conky/derivantArt/easysid/Rainmeter/dinaj.lua
lua_draw_hook_post main
...
Last edited by unklar (2017-01-05 20:26:34)
Offline
https://cdn.scrot.moe/images/2017/01/05/rain_easy.th.jpg
url = "http://www.accuweather.com/de/de/lichtenstein/09350/weather-forecast/171261" url = "http://www.accuweather.com/en/de/lichtenstein/09350/weather-forecast/171261"
Even if the line is ... /en/de/..., no function.
First, I made a mistake, using a bad regex. Forgot to grep for the minus sign. It's fixed now. Use the updated script from the post.
Second, use the 'current-weather' url, instead of the 'weather-forecast'. I'll fix this in the coming iterations, but for now, you have to manually change the url. That too has been fixed. It should work as expected now.
Thanks for the bugs.
Last edited by easysid (2017-01-06 05:47:58)
Offline
^ i did not find the "current-weather" yesterday. German is a difficult language.
![]()
Now everything is OK. The code works correctly. Good work.
Thank you!
Glad to hear it. Set 'testing=0' to get rid of the current temperature message. It is there just to see that if the correct temperature is being pulled by the script.
Offline
Hello
here a vidéo from my techoblivion (a mix from hightec, oblivion & weather is Théo's accuweather script.
https://drive.google.com/open?id=0Bygxc … 0ZfMjc1cEk
is that possible to make better the start script
#!/bin/bash
killall conky
sleep 3
(wmctrl -s 1 && conky -c ~/Oblivion/load/load) & sleep 11
killall conky
conky -c ~/hightech/load/load & sleep 15
killall conky
#
#
# 3. asztal
#
(sleep 3 && wmctrl -s 3) &
(sleep 4 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/cpu/cpu.rc) &
(sleep 4 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/cpu/cpuanim.rc) &
(sleep 4 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/net/net.rc) &
(sleep 4 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/net/netanim.rc) &
(sleep 4 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/net/netanim_wifi.rc) &
(sleep 4 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/anim/bdron.rc) &
(sleep 5 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/media/banshee.rc) &
(sleep 4 && wmctrl -s 3 && conky -c ~/Oblivion/desk2/hdd/hdd.rc) &
#
#
# 2. asztal
#
(sleep 8 && wmctrl -s 2) &
(sleep 8 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/user/user.rc) &
(sleep 8 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/process/process.rc) &
(sleep 8 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/anim/local.rc) &
#(sleep 8 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/weather/weather.rc) &
(sleep 8 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/cpu_bat/cpu_bat.rc) &
(sleep 8 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/anim/anim_command_tech.rc) &
(sleep 8 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/anim/signal.rc) &
(sleep 9 && wmctrl -s 2 && conky -c ~/Oblivion/desk1/user/useranim.rc) &
#
#
#1 .
#
(sleep 20 && wmctrl -s 1) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/mapanim/mapanim) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/graphanim/graphanim) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/weather/weather) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/battery/battery) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/battery/batteryanim) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/hdd/hdd) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/slideshow/slideshow) &
(sleep 3 && wmctrl -s 1 && conky -c ~/hightech/barograph) &
exit
Last edited by loutch (2017-01-07 20:56:30)
Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX
Offline
Hello
here a vidéo from my techoblivion (a mix from hightec, oblivion & weather is Théo's accuweather script.
That's Breathtaking, Bedazzling and Classy all in - well 4 screens
is that possible to make better the start script
Lets talk ...
Start with the beginning ...
#!/bin/bash
killall conky
sleep 3
(wmctrl -s 1 && conky -c ~/Oblivion/load/load) & sleep 11
killall conky
conky -c ~/hightech/load/load & sleep 15
killall conky
#
why sleep 3 then start a conky (load) on Desktop 2 then "killall conkys" after 11 seconds?
and then start the hightech/load conky and killall conkys after 15 seconds?
If those are your OBLIVION and Loading screens try this:
#!/bin/bash
killall conky
(sleep 3 && wmctrl -s 1 && conky -c ~/Oblivion/load/load) &
(sleep 11 && pkill -xf "conky -c ~/Oblivion/load/load") &
(sleep 16 && conky -c ~/hightech/load/load) &
(sleep 31 && pkill -xf "conky -c ~/hightech/load/load") &
## other stuff here
exit 0
Actually I would use the wmctrl to start both conkys - in case you have changed desktops at some time:
#!/bin/bash
killall conky
(sleep 3 && wmctrl -s 1 && conky -c ~/Oblivion/load/load) &
(sleep 11 && pkill -xf "conky -c ~/Oblivion/load/load") &
(sleep 16 && wmctrl -s 1 conky -c ~/hightech/load/load) &
(sleep 31 && pkill -xf "conky -c ~/hightech/load/load") &
## other stuff here
exit 0
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
@loutch,
absolutely brilliant and unique in the world! Hmm, Mageia5
How many years have you worked on it? A first scene I have, so is my memory, 2013 on #! seen.
You are an artist! Thank you!
Offline
@ unklar
Thank you but I am not the creator and all the thanks have to be for Met30 it is he who is at the origin of the conkys.I' just took what pleases me and makes modifications and integrate Théo's accuweather script & any thinks from other conkystador .
@+
Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX
Offline
@loutch,
Yea, I use to say the same type of thing. But here's the thing, as other have told me:
You take a piece of this conky, a piece of that conky, some of this bash script, and a couple of those LUA scripts and tweak the heck out of them all to make something with them all.
=== Online Translator ===
Oui, j'utilise pour dire le même type de chose. Mais voici la chose, comme d'autres m'ont dit:
Vous prenez un morceau de ce conky, un morceau de ce conky, un peu de ce script bash, et un couple de ces scripts LUA et tordre le diable hors de tous pour faire quelque chose avec eux tous.
"That's yours" and you did it beautifully! KUDOS!
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline