-- Standard awesome library
local awful = require("awful")
local hotkeys_popup = require("awful.hotkeys_popup").widget
-- Theme handling library
local beautiful = require("beautiful") -- for awesome.icon

local M = {}  -- menu
local _M = {} -- module

-- reading
-- https://awesomewm.org/apidoc/popups%20and%20bars/awful.menu.html

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

-- This is used later as the default terminal and editor to run.
-- local terminal = "xfce4-terminal"
local terminal = RC.vars.terminal

-- Variable definitions
-- This is used later as the default terminal and editor to run.
local editor = os.getenv("EDITOR") or "nano"
local editor_cmd = terminal .. " -e " .. editor

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

M.awesome = {
  { "hotkeys", function() 
      hotkeys_popup.show_help(nil, awful.screen.focused()) 
    end },
  { "manual", terminal .. " -e man awesome" },
  { "edit config", editor_cmd .. " " .. awesome.conffile },
  { "terminal", terminal },
  { "restart", awesome.restart },
  { "quit", function() awesome.quit() end }
}

M.network = {
  { "firefox", "firefox" },
  { "discord", "flatpak run com.discordapp.Discord" },
  { "thunderbird", "thunderbird" },
  { "steam", "flatpak run com.valvesoftware.Steam" },
  { "qbittorrent", "qbittorrent" },
  { "keepassxc", "keepassxc" },
}

M.develop = {
  { "vs code", "flatpak run com.visualstudio.code" },
  { "bless", "bless" },
  { "beekeeper studio", "flatpak run io.beekeeperstudio.Studio" },
  { "sqlite browser", "sqlitebrowser" }
}

M.emulators = {
  { "citra", "flatpak run org.citra_emu.citra" },
  { "dolphin", "flatpak run org.DolphinEmu.dolphin-emu" },
  { "yuzu", "flatpak run org.yuzu_emu.yuzu"}
}

M.games = {
  { "emulators", M.emulators },
  { "vintage story", "flatpak run at.vintagestory.VintageStory" },
  { "osu!", "flatpak run sh.ppy.osu" }
}

M.utils = {
  { "catfish", "catfish" },
  { "text pieces", "flatpak run com.github.liferooter.textpieces" },
  { "flatseal", "flatpak run com.github.tchx84.Flatseal" },
  { "piper", "piper" }
}

M.media = {
  { "youtube", "/usr/lib64/chromium-browser/chromium-browser.sh --profile-directory=Default --app-id=agimnkijcaahngcdmfeangaknmldooml"},
  { "spotify", "flatpak run com.spotify.Client" }
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

function _M.get()

  -- Main Menu
  local menu_items = {
    { "awesome", M.awesome, beautiful.awesome_subicon },
    { "terminal", terminal },
    { "thunar", "Thunar" },
    { "www", M.network },
    { "media", M.media },
    { "dev", M.develop },
    { "games", M.games },
    { "utils", M.utils },
--    { "maim (select)", "maim -s $(HOME)$(date +%s)" },
  }

  return menu_items
end

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

return setmetatable({}, { __call = function(_, ...) return _M.get(...) end })
