mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
Moved API key and coordinated to separate file
This commit is contained in:
parent
835d1d64a7
commit
908578e892
@ -2,9 +2,8 @@
|
||||
-- found (e.g. lgi). If LuaRocks is not installed, do nothing.
|
||||
pcall(require, "luarocks.loader")
|
||||
|
||||
-- Awesome Wm Widgets
|
||||
-- AwesomeWM Widgets
|
||||
local cpu_widget = require("awesome-wm-widgets.cpu-widget.cpu-widget")
|
||||
local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness")
|
||||
local spotify_widget = require("awesome-wm-widgets.spotify-widget.spotify")
|
||||
local volume_widget = require("awesome-wm-widgets.volume-widget.volume")
|
||||
local net_speed_widget = require("awesome-wm-widgets.net-speed-widget.net-speed")
|
||||
@ -29,6 +28,32 @@ local hotkeys_popup = require("awful.hotkeys_popup")
|
||||
-- when client with a matching name is opened:
|
||||
require("awful.hotkeys_popup.keys")
|
||||
|
||||
-- OpenWeather API
|
||||
-- !Create file ~/.config/awesome/weather and paste API from OpenWeather, latitude and longitude, each on separate lines
|
||||
local weather_file = '/home/kristofers/.config/awesome/weather' -- absolute path to `weather` file
|
||||
-- see if the file exists
|
||||
local function file_exists(file)
|
||||
local f = io.open(file, "rb")
|
||||
if f then f:close() end
|
||||
return f ~= nil
|
||||
end
|
||||
|
||||
-- get all lines from a file, returns an empty
|
||||
-- list/table if the file does not exist
|
||||
local function lines_from(file)
|
||||
if not file_exists(file) then return {} end
|
||||
local lines = {}
|
||||
for line in io.lines(file) do
|
||||
lines[#lines + 1] = line
|
||||
end
|
||||
return lines
|
||||
end
|
||||
|
||||
local weather_output = lines_from(weather_file)
|
||||
local API = weather_output[1]
|
||||
local latitude = tonumber(weather_output[2])
|
||||
local longitude = tonumber(weather_output[3])
|
||||
|
||||
|
||||
-- {{{ Error handling
|
||||
-- Check if awesome encountered an error during startup and fell back to
|
||||
@ -244,8 +269,8 @@ awful.screen.connect_for_each_screen(function(s)
|
||||
max_lenght = -1,
|
||||
}),
|
||||
weather_widget({
|
||||
api_key = '3bc28ba1ee6eeaf28af31d9d948aecd1',
|
||||
coordinates = { 56.861415323546815, 24.386162623793343 },
|
||||
api_key = API,
|
||||
coordinates = { latitude, longitude },
|
||||
show_daily_forecast = true,
|
||||
}),
|
||||
--volume_widget{
|
||||
@ -274,6 +299,9 @@ globalkeys = gears.table.join(
|
||||
awful.key({}, "Pause", function() awful.spawn.with_shell("playerctl -a play-pause") end,
|
||||
{ description = "pause/play", group = "media controls" }),
|
||||
|
||||
awful.key({ "Control" }, "Pause", function() awful.spawn.with_shell("playerctl -a pause") end,
|
||||
{ description = "pause all", group = "media controls" }),
|
||||
|
||||
awful.key({}, "#117", function() awful.spawn.with_shell("playerctl next") end,
|
||||
{ description = "play next", group = "media controls" }),
|
||||
|
||||
@ -581,8 +609,8 @@ client.connect_signal("manage", function(c)
|
||||
-- if not awesome.startup then awful.client.setslave(c) end
|
||||
|
||||
if awesome.startup
|
||||
and not c.size_hints.user_position
|
||||
and not c.size_hints.program_position then
|
||||
and not c.size_hints.user_position
|
||||
and not c.size_hints.program_position then
|
||||
-- Prevent clients from being unreachable after screen count changes.
|
||||
awful.placement.no_offscreen(c)
|
||||
end
|
||||
|
||||
@ -30,6 +30,32 @@ local hotkeys_popup = require("awful.hotkeys_popup")
|
||||
-- when client with a matching name is opened:
|
||||
require("awful.hotkeys_popup.keys")
|
||||
|
||||
-- OpenWeather API
|
||||
-- !Create file ~/.config/awesome/weather and paste API from OpenWeather, latitude and longitude, each on separate lines
|
||||
local weather_file = '/home/kristofers/.config/awesome/weather' -- absolute path to `weather` file
|
||||
-- see if the file exists
|
||||
local function file_exists(file)
|
||||
local f = io.open(file, "rb")
|
||||
if f then f:close() end
|
||||
return f ~= nil
|
||||
end
|
||||
|
||||
-- get all lines from a file, returns an empty
|
||||
-- list/table if the file does not exist
|
||||
local function lines_from(file)
|
||||
if not file_exists(file) then return {} end
|
||||
local lines = {}
|
||||
for line in io.lines(file) do
|
||||
lines[#lines + 1] = line
|
||||
end
|
||||
return lines
|
||||
end
|
||||
|
||||
local weather_output = lines_from(weather_file)
|
||||
local API = weather_output[1]
|
||||
local latitude = tonumber(weather_output[2])
|
||||
local longitude = tonumber(weather_output[3])
|
||||
|
||||
|
||||
-- {{{ Error handling
|
||||
-- Check if awesome encountered an error during startup and fell back to
|
||||
@ -255,8 +281,8 @@ awful.screen.connect_for_each_screen(function(s)
|
||||
tooltip = true,
|
||||
},
|
||||
weather_widget({
|
||||
api_key = '3bc28ba1ee6eeaf28af31d9d948aecd1',
|
||||
coordinates = { 56.86140361300421, 24.386173343039193 },
|
||||
api_key = API,
|
||||
coordinates = { latitude, longitude },
|
||||
show_hourly_forecst = true,
|
||||
show_daily_forecast = true,
|
||||
}),
|
||||
@ -567,8 +593,8 @@ client.connect_signal("manage", function(c)
|
||||
-- if not awesome.startup then awful.client.setslave(c) end
|
||||
|
||||
if awesome.startup
|
||||
and not c.size_hints.user_position
|
||||
and not c.size_hints.program_position then
|
||||
and not c.size_hints.user_position
|
||||
and not c.size_hints.program_position then
|
||||
-- Prevent clients from being unreachable after screen count changes.
|
||||
awful.placement.no_offscreen(c)
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user