Reorganize icons array and add text icons

This commit is contained in:
elenapan 2020-06-20 17:06:28 +03:00
parent 83442642f7
commit 39af6d9f92
17 changed files with 129 additions and 118 deletions

View file

@ -223,7 +223,9 @@ After setting up my AwesomeWM configuration, inside `~/.config/awesome` you will
Here you can find a directory for each available icon theme and an `init.lua` file which initializes the `icons` variables.
For example, `icons.firefox` can be used to refer to your selected theme's Firefox icon instead of using the full path to the image. This makes it easy to switch between themes.
Icons can be images taken from the selected icon theme or text symbols taken from some icon font.
For example, `icons.image.firefox` can be used to refer to your selected theme's Firefox icon instead of using the full path to the image. This makes it easy to switch between themes.
Note: Icon themes defined here have nothing to do with your system-wide icon theme.

View file

@ -79,7 +79,7 @@ apps.night_mode = function ()
local cmd = "pgrep redshift > /dev/null && (pkill redshift && echo 'OFF') || (echo 'ON' && redshift -l 0:0 -t 3700:3700 -r &>/dev/null &)"
awful.spawn.easy_async_with_shell(cmd, function(out)
local message = out:match('ON') and "Activated!" or "Deactivated!"
night_mode_notif = notifications.notify_dwim({ title = "Night mode", message = message, app_name = "night_mode", icon = icons.redshift }, night_mode_notif)
night_mode_notif = notifications.notify_dwim({ title = "Night mode", message = message, app_name = "night_mode", icon = icons.image.redshift }, night_mode_notif)
end)
end
@ -88,7 +88,7 @@ apps.screenkey = function ()
local cmd = "pgrep screenkey > /dev/null && (pkill screenkey && echo 'OFF') || (echo 'ON' && screenkey --ignore Caps_Lock --bg-color '#FFFFFF' --font-color '#000000' &>/dev/null &)"
awful.spawn.easy_async_with_shell(cmd, function(out)
local message = out:match('ON') and "Activated!" or "Deactivated!"
screenkey_notif = notifications.notify_dwim({ title = "Screenkey", message = message, app_name = "screenkey", icon = icons.keyboard }, screenkey_notif)
screenkey_notif = notifications.notify_dwim({ title = "Screenkey", message = message, app_name = "screenkey", icon = icons.image.keyboard }, screenkey_notif)
end)
end
@ -154,7 +154,7 @@ function apps.screenshot(action, delay)
local timestamp = os.date("%Y.%m.%d-%H.%M.%S")
local filename = user.dirs.screenshots..timestamp..".screenshot.png"
local maim_args = "-u -b 3 -m 5"
local icon = icons.screenshot
local icon = icons.image.screenshot
local prefix
if delay then

View file

@ -13,7 +13,7 @@ local desktop_control = require("noodle.desktop_control")
local minimal_tasklist = require("noodle.minimal_tasklist")
-- Start button widget (can toggle sidebar, tray, scratchpad)
start_widget = wibox.widget.imagebox(icons.start)
start_widget = wibox.widget.imagebox(icons.image.start)
start_widget:buttons(gears.table.join(
-- Left click - Toggle sidebar
awful.button({ }, 1, function ()

View file

@ -516,7 +516,7 @@ screenshot_box:buttons(gears.table.join(
end),
-- Right click - Take screenshot in 5 seconds
awful.button({ }, 3, function ()
naughty.notify({title = "Say cheese!", text = "Taking shot in 5 seconds", timeout = 4, icon = icons.screenshot})
naughty.notify({title = "Say cheese!", text = "Taking shot in 5 seconds", timeout = 4, icon = icons.image.screenshot})
apps.screenshot("full", 5)
end)
))

View file

@ -333,7 +333,7 @@ helpers.add_hover_cursor(fortune_box, "hand1")
local icon_size = dpi(40)
local brightness_icon = wibox.widget.imagebox(icons.redshift)
local brightness_icon = wibox.widget.imagebox(icons.image.redshift)
brightness_icon.resize = true
brightness_icon.forced_width = icon_size
brightness_icon.forced_height = icon_size
@ -390,7 +390,7 @@ brightness_box:buttons(
helpers.add_hover_cursor(brightness_box, "hand1")
local notification_state = wibox.widget.imagebox(icons.alarm)
local notification_state = wibox.widget.imagebox(icons.image.alarm)
notification_state.resize = true
notification_state.forced_width = icon_size
notification_state.forced_height = icon_size
@ -398,9 +398,9 @@ notification_state.forced_height = icon_size
-- notification_state.font = "Material Design Icons 30"
local function update_notification_state_icon()
if naughty.suspended then
notification_state.image = icons.alarm_off
notification_state.image = icons.image.alarm_off
else
notification_state.image = icons.alarm
notification_state.image = icons.image.alarm
end
end
update_notification_state_icon()
@ -415,7 +415,7 @@ notification_state_box:buttons(gears.table.join(
helpers.add_hover_cursor(notification_state_box, "hand1")
local screenshot = wibox.widget.imagebox(icons.screenshot)
local screenshot = wibox.widget.imagebox(icons.image.screenshot)
screenshot.resize = true
screenshot.forced_width = icon_size
screenshot.forced_height = icon_size
@ -429,7 +429,7 @@ screenshot_box:buttons(gears.table.join(
end),
-- Right click - Take screenshot in 5 seconds
awful.button({ }, 3, function ()
naughty.notify({title = "Say cheese!", text = "Taking shot in 5 seconds", timeout = 4, icon = icons.screenshot})
naughty.notify({title = "Say cheese!", text = "Taking shot in 5 seconds", timeout = 4, icon = icons.image.screenshot})
apps.screenshot("full", 5)
end)
))

View file

@ -38,7 +38,7 @@ local username = os.getenv("USER")
local goodbye_widget = wibox.widget.textbox("Goodbye " .. username:sub(1,1):upper()..username:sub(2))
goodbye_widget.font = "sans 70"
local poweroff_icon = wibox.widget.imagebox(icons.poweroff)
local poweroff_icon = wibox.widget.imagebox(icons.image.poweroff)
poweroff_icon.resize = true
poweroff_icon.forced_width = icon_size
poweroff_icon.forced_height = icon_size
@ -67,7 +67,7 @@ poweroff:buttons(gears.table.join(
end)
))
local reboot_icon = wibox.widget.imagebox(icons.reboot)
local reboot_icon = wibox.widget.imagebox(icons.image.reboot)
reboot_icon.resize = true
reboot_icon.forced_width = icon_size
reboot_icon.forced_height = icon_size
@ -98,7 +98,7 @@ reboot:buttons(gears.table.join(
end)
))
local suspend_icon = wibox.widget.imagebox(icons.suspend)
local suspend_icon = wibox.widget.imagebox(icons.image.suspend)
suspend_icon.resize = true
suspend_icon.forced_width = icon_size
suspend_icon.forced_height = icon_size
@ -130,7 +130,7 @@ suspend:buttons(gears.table.join(
))
local exit_icon = wibox.widget.imagebox(icons.exit)
local exit_icon = wibox.widget.imagebox(icons.image.exit)
exit_icon.resize = true
exit_icon.forced_width = icon_size
exit_icon.forced_height = icon_size
@ -161,7 +161,7 @@ exit:buttons(gears.table.join(
end)
))
local lock_icon = wibox.widget.imagebox(icons.lock)
local lock_icon = wibox.widget.imagebox(icons.image.lock)
lock_icon.resize = true
lock_icon.forced_width = icon_size
lock_icon.forced_height = icon_size

View file

@ -43,7 +43,7 @@ local function format_progress_bar(bar, icon)
end
-- Item configuration
local exit_icon = wibox.widget.imagebox(icons.poweroff)
local exit_icon = wibox.widget.imagebox(icons.image.poweroff)
exit_icon.resize = true
exit_icon.forced_width = icon_size
exit_icon.forced_height = icon_size
@ -86,7 +86,7 @@ local weather = wibox.widget{
}
local temperature_icon = wibox.widget.imagebox(icons.temperature)
local temperature_icon = wibox.widget.imagebox(icons.image.temperature)
local temperature_bar = require("noodle.temperature_bar")
local temperature = format_progress_bar(temperature_bar, temperature_icon)
temperature:buttons(
@ -94,18 +94,18 @@ temperature:buttons(
awful.button({ }, 1, apps.temperature_monitor)
))
local battery_icon = wibox.widget.imagebox(icons.battery)
local battery_icon = wibox.widget.imagebox(icons.image.battery)
awesome.connect_signal("evil::charger", function(plugged)
if plugged then
battery_icon.image = icons.battery_charging
battery_icon.image = icons.image.battery_charging
else
battery_icon.image = icons.battery
battery_icon.image = icons.image.battery
end
end)
local battery_bar = require("noodle.battery_bar")
local battery = format_progress_bar(battery_bar, battery_icon)
local cpu_icon = wibox.widget.imagebox(icons.cpu)
local cpu_icon = wibox.widget.imagebox(icons.image.cpu)
local cpu_bar = require("noodle.cpu_bar")
local cpu = format_progress_bar(cpu_bar, cpu_icon)
@ -115,7 +115,7 @@ cpu:buttons(
awful.button({ }, 3, apps.process_monitor_gui)
))
local ram_icon = wibox.widget.imagebox(icons.ram)
local ram_icon = wibox.widget.imagebox(icons.image.ram)
local ram_bar = require("noodle.ram_bar")
local ram = format_progress_bar(ram_bar, ram_icon)
@ -125,7 +125,7 @@ ram:buttons(
awful.button({ }, 3, apps.process_monitor_gui)
))
local playerctl_toggle_icon = wibox.widget.imagebox(icons.playerctl_toggle)
local playerctl_toggle_icon = wibox.widget.imagebox(icons.image.playerctl_toggle)
playerctl_toggle_icon.resize = true
playerctl_toggle_icon.forced_width = playerctl_button_size
playerctl_toggle_icon.forced_height = playerctl_button_size
@ -138,7 +138,7 @@ playerctl_toggle_icon:buttons(gears.table.join(
end)
))
local playerctl_prev_icon = wibox.widget.imagebox(icons.playerctl_prev)
local playerctl_prev_icon = wibox.widget.imagebox(icons.image.playerctl_prev)
playerctl_prev_icon.resize = true
playerctl_prev_icon.forced_width = playerctl_button_size
playerctl_prev_icon.forced_height = playerctl_button_size
@ -151,7 +151,7 @@ playerctl_prev_icon:buttons(gears.table.join(
end)
))
local playerctl_next_icon = wibox.widget.imagebox(icons.playerctl_next)
local playerctl_next_icon = wibox.widget.imagebox(icons.image.playerctl_next)
playerctl_next_icon.resize = true
playerctl_next_icon.forced_width = playerctl_button_size
playerctl_next_icon.forced_height = playerctl_button_size
@ -247,7 +247,7 @@ mpd_song:buttons(gears.table.join(
local disk_space = require("noodle.disk")
disk_space.font = "sans 14"
local disk_icon = wibox.widget.imagebox(icons.files)
local disk_icon = wibox.widget.imagebox(icons.image.files)
disk_icon.resize = true
disk_icon.forced_width = icon_size
disk_icon.forced_height = icon_size
@ -272,7 +272,7 @@ disk:buttons(gears.table.join(
end)
))
local search_icon = wibox.widget.imagebox(icons.search)
local search_icon = wibox.widget.imagebox(icons.image.search)
search_icon.resize = true
search_icon.forced_width = icon_size
search_icon.forced_height = icon_size
@ -295,7 +295,7 @@ search:buttons(gears.table.join(
end)
))
local volume_icon = wibox.widget.imagebox(icons.volume)
local volume_icon = wibox.widget.imagebox(icons.image.volume)
local volume_bar = require("noodle.volume_bar")
local volume = format_progress_bar(volume_bar, volume_icon)

View file

@ -5,6 +5,8 @@ local helpers = require("helpers")
local keys = require("keys")
local gears = require("gears")
local capi = { screen = screen, client = client }
local icons = require("icons")
local class_icons = icons.text.by_class
-- TODO ability to switch to specific minimized clients without using the mouse:
-- Might need to ditch the "easy" tasklist approach for something manual
@ -13,55 +15,6 @@ local window_switcher_margin = dpi(10)
local item_height = dpi(50)
local item_width = dpi(500)
-- Set up text symbols and colors to be used instead of awful.widget.clienticon
-- Based on the client's `class` property
local class_icons = {
-- Terminals
['kitty'] = { symbol = "", color = x.color5 },
['Alacritty'] = { symbol = "", color = x.color5 },
['Termite'] = { symbol = "", color = x.color5 },
['URxvt'] = { symbol = "", color = x.color5 },
['st'] = { symbol = "", color = x.color5 },
['st-256color'] = { symbol = "", color = x.color5 },
-- Image viewers
['feh'] = { symbol = "", color = x.color1 },
['Sxiv'] = { symbol = "", color = x.color1 },
-- General
['TelegramDesktop'] = { symbol = "", color = x.color4 },
['Firefox'] = { symbol = "", color = x.color3 },
['firefox'] = { symbol = "", color = x.color3 },
['Chromium'] = { symbol = "", color = x.color4 },
['Chromium-browser'] = { symbol = "", color = x.color4 },
['Steam'] = { symbol = "", color = x.color2 },
['Lutris'] = { symbol = "", color = x.color6 },
['editor'] = { symbol = "", color = x.color5 },
['Emacs'] = { symbol = "", color = x.color5 },
['email'] = { symbol = "", color = x.color6 },
['music'] = { symbol = "", color = x.color6 },
['mpv'] = { symbol = "", color = x.color6 },
['KeePassXC'] = { symbol = "", color = x.color1 },
['Gucharmap'] = { symbol = "", color = x.color6 },
['Pavucontrol'] = { symbol = "", color = x.color4 },
['htop'] = { symbol = "", color = x.color2 },
['Screenruler'] = { symbol = "", color = x.color3 },
['Galculator'] = { symbol = "", color = x.color2 },
['Zathura'] = { symbol = "", color = x.color2 },
-- File managers
['Thunar'] = { symbol = "", color = x.color3 },
['Nemo'] = { symbol = "", color = x.color3 },
['Gimp'] = { symbol = "", color = x.color4 },
['Inkscape'] = { symbol = "", color = x.color2 },
['Gpick'] = { symbol = "", color = x.color6 },
-- Default
['_'] = { symbol = "", color = x.color7.."99" }
}
local window_switcher_hide
local get_num_clients
awful.screen.connect_for_each_screen(function(s)

View file

@ -293,7 +293,7 @@ function helpers.prompt(action, textbox, prompt, callback)
exe_callback = function(input)
if not input or #input == 0 then return end
awful.spawn.with_shell("noglob "..user.web_search_cmd.."'"..input.."'")
naughty.notify { title = "Searching the web for", text = input, icon = icons.firefox }
naughty.notify { title = "Searching the web for", text = input, icon = icons.image.firefox }
end
}
end

View file

@ -11,9 +11,63 @@ local function file_exists(path)
end
local icons = {}
icons.image = {}
icons.text = {}
-- TODO Set up weather text icons here instead of in ../noodle/text_weather.lua
-- icons.text.weather = {}
-- Set up text symbols and accent colors to be used in tasklists or docks
-- instead of awful.widget.clienticon
-- Based on the client's `class` property
icons.text.by_class = {
-- Terminals
['kitty'] = { symbol = "", color = x.color5 },
['Alacritty'] = { symbol = "", color = x.color5 },
['Termite'] = { symbol = "", color = x.color5 },
['URxvt'] = { symbol = "", color = x.color5 },
['st'] = { symbol = "", color = x.color5 },
['st-256color'] = { symbol = "", color = x.color5 },
-- Image viewers
['feh'] = { symbol = "", color = x.color1 },
['Sxiv'] = { symbol = "", color = x.color1 },
-- General
['TelegramDesktop'] = { symbol = "", color = x.color4 },
['Firefox'] = { symbol = "", color = x.color3 },
['firefox'] = { symbol = "", color = x.color3 },
['Chromium'] = { symbol = "", color = x.color4 },
['Chromium-browser'] = { symbol = "", color = x.color4 },
['Steam'] = { symbol = "", color = x.color2 },
['Lutris'] = { symbol = "", color = x.color6 },
['editor'] = { symbol = "", color = x.color5 },
['Emacs'] = { symbol = "", color = x.color5 },
['email'] = { symbol = "", color = x.color6 },
['music'] = { symbol = "", color = x.color6 },
['mpv'] = { symbol = "", color = x.color6 },
['KeePassXC'] = { symbol = "", color = x.color1 },
['Gucharmap'] = { symbol = "", color = x.color6 },
['Pavucontrol'] = { symbol = "", color = x.color4 },
['htop'] = { symbol = "", color = x.color2 },
['Screenruler'] = { symbol = "", color = x.color3 },
['Galculator'] = { symbol = "", color = x.color2 },
['Zathura'] = { symbol = "", color = x.color2 },
-- File managers
['Thunar'] = { symbol = "", color = x.color3 },
['Nemo'] = { symbol = "", color = x.color3 },
['Gimp'] = { symbol = "", color = x.color4 },
['Inkscape'] = { symbol = "", color = x.color2 },
['Gpick'] = { symbol = "", color = x.color6 },
-- Default
['_'] = { symbol = "", color = x.color7.."99" }
}
-- Available icons
local icon_names = {
local image_icon_names = {
"playerctl_toggle",
"playerctl_prev",
"playerctl_next",
@ -75,19 +129,21 @@ local p
-- Assumes all the icon files end in .png
-- TODO maybe automatically detect icons in icon theme directory
local function set_icon(icon_name)
local function set_image_icon(icon_name)
local i = p..icon_name..".png"
icons[icon_name] = i
icons.image[icon_name] = i
end
-- Set all the icon variables
function icons.init(theme_name)
-- Set the path to icons
-- Set the path to image icons
p = gears.filesystem.get_configuration_dir().."icons/"..theme_name.."/"
for i = 1, #icon_names do
set_icon(icon_names[i])
for i = 1, #image_icon_names do
set_image_icon(image_icon_names[i])
end
-- Set symbols and accent colors for text icons
end
return icons

View file

@ -20,7 +20,7 @@ local weather_text = wibox.widget{
widget = wibox.widget.textbox
}
local weather_icon = wibox.widget.imagebox(icons.whatever)
local weather_icon = wibox.widget.imagebox(icons.image.whatever)
weather_icon.resize = true
weather_icon.forced_width = 40
weather_icon.forced_height = 40
@ -32,27 +32,27 @@ local weather = wibox.widget{
}
local weather_icons = {
["01d"] = icons.sun,
["01n"] = icons.star,
["02d"] = icons.dcloud,
["02n"] = icons.ncloud,
["03d"] = icons.cloud,
["03n"] = icons.cloud,
["04d"] = icons.cloud,
["04n"] = icons.cloud,
["09d"] = icons.rain,
["09n"] = icons.rain,
["10d"] = icons.rain,
["10n"] = icons.rain,
["11d"] = icons.storm,
["11n"] = icons.storm,
["13d"] = icons.snow,
["13n"] = icons.snow,
["40d"] = icons.mist,
["40n"] = icons.mist,
["50d"] = icons.mist,
["50n"] = icons.mist,
["_"] = icons.whatever,
["01d"] = icons.image.sun,
["01n"] = icons.image.star,
["02d"] = icons.image.dcloud,
["02n"] = icons.image.ncloud,
["03d"] = icons.image.cloud,
["03n"] = icons.image.cloud,
["04d"] = icons.image.cloud,
["04n"] = icons.image.cloud,
["09d"] = icons.image.rain,
["09n"] = icons.image.rain,
["10d"] = icons.image.rain,
["10n"] = icons.image.rain,
["11d"] = icons.image.storm,
["11n"] = icons.image.storm,
["13d"] = icons.image.snow,
["13n"] = icons.image.snow,
["40d"] = icons.image.mist,
["40n"] = icons.image.mist,
["50d"] = icons.image.mist,
["50n"] = icons.image.mist,
["_"] = icons.image.whatever,
}
awesome.connect_signal("evil::weather", function(temperature, description, icon_code)

View file

@ -24,7 +24,7 @@ awesome.connect_signal("evil::battery", function(battery)
return
end
if not charger_plugged then
icon = icons.battery
icon = icons.image.battery
if battery <= user.battery_threshold_critical and not battery_critical_already_notified then
battery_critical_already_notified = true
message = "CRITICAL"
@ -37,7 +37,7 @@ awesome.connect_signal("evil::battery", function(battery)
timeout = 6
end
else
icon = icons.battery_charging
icon = icons.image.battery_charging
if battery > battery_full_threshold and not battery_full_already_notified then
battery_full_already_notified = true
message = "Full"
@ -63,11 +63,11 @@ awesome.connect_signal("evil::charger", function(plugged)
-- Avoids notifying of a full battery if it was almost full after plugging
battery_full_already_notified = battery_current > battery_full_threshold
message = "Plugged"
icon = icons.battery_charging
icon = icons.image.battery_charging
else
battery_full_already_notified = false
message = "Unplugged"
icon = icons.battery
icon = icons.image.battery
end
-- Do not send a notification the first time (when AwesomeWM (re)starts)

View file

@ -18,7 +18,7 @@ awesome.connect_signal("evil::brightness", function (percentage)
end
else
-- Send notification
notif = notifications.notify_dwim({ title = "Brightness", message = tostring(percentage), icon = icons.redshift, timeout = timeout, app_name = "brightness" }, notif)
notif = notifications.notify_dwim({ title = "Brightness", message = tostring(percentage), icon = icons.image.redshift, timeout = timeout, app_name = "brightness" }, notif)
end
end
end)

View file

@ -9,5 +9,5 @@ local notif
-- updates in order to send a notification whenerver needed.
local dummy_keyboardlayout_widget = awful.widget.keyboardlayout()
dummy_keyboardlayout_widget:connect_signal("widget::redraw_needed", function ()
notif = notifications.notify_dwim({ title = "Keyboard layout", message = dummy_keyboardlayout_widget.widget.text:upper(), icon = icons.keyboard, timeout = 1, app_name = "keyboard" }, notif)
notif = notifications.notify_dwim({ title = "Keyboard layout", message = dummy_keyboardlayout_widget.widget.text:upper(), icon = icons.image.keyboard, timeout = 1, app_name = "keyboard" }, notif)
end)

View file

@ -25,7 +25,7 @@ table.insert(awful.rules.rules, {
c.urgent_first_time = true
c:connect_signal("property::urgent", function()
if c.urgent and not c.urgent_first_time then
league_notif = notifications.notify_dwim({ title = "League of Legends", message = "is desperate for your attention", icon = icons.games, timeout = 15, app_name = "League of Legends", actions = { jump_to_client } }, league_notif)
league_notif = notifications.notify_dwim({ title = "League of Legends", message = "is desperate for your attention", icon = icons.image.games, timeout = 15, app_name = "League of Legends", actions = { jump_to_client } }, league_notif)
else
if league_notif then
league_notif:destroy()

View file

@ -30,7 +30,7 @@ local send_mpd_notif = function (artist, song, paused)
{
title = "Now playing:",
message = "<b>"..song.."</b> by <b>"..artist.."</b>",
icon = icons.music,
icon = icons.image.music,
timeout = timeout,
app_name = "mpd"
},

View file

@ -20,10 +20,10 @@ awesome.connect_signal("evil::volume", function (percentage, muted)
local message, icon
if muted then
message = "muted"
icon = icons.muted
icon = icons.image.muted
else
message = tostring(percentage)
icon = icons.volume
icon = icons.image.volume
end
notif = notifications.notify_dwim({ title = "Volume", message = message, icon = icon, timeout = timeout, app_name = "volume" }, notif)