diff --git a/README.md b/README.md index 588301c..edcc840 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,380 @@ -# Crylia Theme - -This theme is inspired by simple bar and many other things that I think look good and fit my theme. AwesomeWM lets you configure your desktop as you want, no compromises, the sky is the limit! -This is the reason I choose AwesomeWM. - -![Desktop](./desktop.png) - -![Lockscreen](./lockscreen.png) - -## FAQ - Wiki +
+

Crylia Theme

+
--- -If you feel lost, got a problem or just have a question, please check out the wiki first before opening an issue. +![Desktop](./assets/desktop.png) -## Quick Install +![Lockscreen](./assets/lockscreen.png) --- -### [Installation](https://github.com/Crylia/crylia-theme/wiki/Guide) +
+

Welcome to my dotfiles

+
+
-Installing this theme is rather easy, just copy the repo and put the awesome folder to ~/.config/ -But in order for it to work as seen you need some dependencies installed along the way. Here are the main components, but in order for everything to work go [here](https://github.com/Crylia/crylia-theme/wiki/Guide). +An AwesomeWM theme inspired by everything I could find online and thought "Hey, that looks good!". -||Arch|Ubuntu|Why?| -|:-:|:-:|:-:|:-:| -|AwesomeWM|awesome|[Guide here](https://github.com/awesomeWM/awesome)|Its your Window Manager lol| -|Rofi|rofi|[Guide here](https://github.com/davatorium/rofi)|For the application launcher| -|Picom|picom-ibhagwan-gitaur|[Guide here](https://github.com/jonaburg/picom/security)|Compositor, needed for transparency/blur/effects/animations etc| -||||| +This repository holds mainly my AwesomeWM theme but also some other rice's I've done over the years. + +Everything you see is done purely because I hate myself and like to give myself a hard time. +
+ + +## Information + +--- + + +**My system setup**: + +- **OS**: [Pop!_OS](https://pop.system76.com/) +- **WM**: [AwesomeWM](https://github.com/awesomeWM/awesome) +- **Terminal**: [Alacritty](https://github.com/alacritty/alacritty) +- **Shell**: [ZSH](https://github.com/ohmyzsh/ohmyzsh) +- **Compositor**: [Picom](https://github.com/jonaburg/picom) +- **Application Launcher**: [Rofi](https://github.com/davatorium/rofi) +- **File Manager**: [Thunar](https://github.com/xfce-mirror/thunar) +- **Icons**: [Papirus-Dark](https://github.com/PapirusDevelopmentTeam/papirus-icon-theme) +- **Cursor**: [Vimix-Cursors](https://github.com/vinceliuice/Vimix-cursors) +- **Font**: [JetBrainsMonoNerdFont](https://www.nerdfonts.com/font-downloads) +- **Editor**: [VS Code](https://code.visualstudio.com/) + + +## Installation + +--- + +#### Here are three levels of what you need + +1. Dependencies you need to have in order for the rice to work +2. Important dependencies but can be replaced, the theme might behave weird without these or without proper reconfiguration! +3. Nice to have and are the default. Can be easily changed without any worries! + +
+1. Dependencies + +#### **AwesomeWM** + +>**Arch** + +```bash +yay -S awesome-git +``` + +> **Ubuntu** + +```bash +sudo apt build-dep awesome +git clone https://github.com/awesomeWM/awesome.git +make package +sudo dpkg -i awesome*.deb +``` + +#### **Rofi** + +>**Arch** + +```bash +yay -S rofi-git +``` + +>**Ubuntu** + +Check [HERE](https://github.com/davatorium/rofi/blob/next/INSTALL.md) for how to build from source. Note **DO NOT INSTAL ROFI FROM APT IT WONT WORK** + +#### **Picom** + +> **Arch** + +```bash +yay -S picom-jonaburg-git +``` + +> **Ubuntu** + +```bash +git clone https://github.com/jonaburg/picom +cd picom +meson --buildtype=release . build +sudo ninja -C build install +``` + +
+
+ +
+ +2. Important Dependencies + +#### **Papirus** - Icon Theme + +***Make sure the theme is located at `/usr/share/icons/`*** + +> **Arch** + +```bash +sudo pacman -S papirus-icon-theme +``` + +> **Ubuntu** + +```bash +sudo apt install papirus-icon-theme +``` + +#### **pactl - PulseAudio Controler** + +***All audio scripts depends on this*** + +> **Arch** + +```bash +sudo pacman -S pulseaudio-alsa +``` + +> **Ubuntu** + +```bash +sudo apt install pulseaudio-utils +``` + +#### **upower - Battery Info** + +> **Arch** + +```bash +sudo pacman -S upower +``` + +> **Ubuntu** + +```bash +sudo apt install upower +``` + +#### **bluez/bluetoothctl - Bluetooth** + +> **Arch** + +```bash +sudo pacman -S bluez bluez-utils +``` + +> **Ubuntu** + +```bash +sudo apt install bluez bluez-utils +``` + +#### **setxkbmap - Change Keyboard Layout** + +> **Arch** + +```bash +sudo pacman -S xorg-setxkbmap +``` + +> **Ubuntu** + +```bash +sudo apt install xorg +``` + +#### **xfce4-power-manager - Backlight** + +> **Arch** + +```bash +sudo pacman -S xfce4-power-manager +``` + +> **Ubuntu** + +```bash +sudo apt install xfce4-power-manager +``` + +#### **playerctl - Media control** + +> **Arch** + +```bash +sudo pacman -S playerctl +``` + +> **Ubuntu** + +```bash +sudo apt install playerctl +``` + +#### **LightDM - Login/Logout/ScreenLock** + +> **Arch** + +```bash +sudo pacman -S lightdm light-locker +``` + +> **Ubuntu** + +```bash +sudo apt install lightdm light-locker +``` +
+ +
+3. Optional Dependencies + +#### **Alacritty** - Default terminal + +> **Arch** + +```bash +sudo pacman -S alacritty +``` + +> **Ubuntu** + +```bash +sudo apt install alacritty +``` + +#### **Thunar** - Default file manager + +> **Arch** + +```bash +sudo pacman -S thunar +``` + +> **Ubuntu** + +```bash +sudo apt install thunar +``` + +#### **Flameshot - Screenshots** + +> **Arch** + +```bash +sudo pacman -S flameshot +``` + +> **Ubuntu** + +```bash +sudo apt install flameshot +``` + +
+ +#### Setup + +Make sure to backup any data before you copy my theme over! + +```bash +git clone https://github.com/Crylia/crylia-theme +cd crylia-theme +cp -r awesome ~/.config/. +cp -r picom.conf ~/.config/. +cp -r rofi ~/.config/. +``` + +Optional + +```bash +cp -r alacritty ~/.config/. +``` + +## [Documentation | Wiki | FAQ](https://github.com/Crylia/crylia-theme/wiki/Documentation) ## Features --- -Some would say there are more features than a WM needs, I say you can never have enough features (as long as they make some sense). +#### Some notable features - [x] Multi screen support -- [x] Interactive taskbar (left, right click and hover over) +- [x] Interactive task/taglist and dock (left, right click and hover over) - [x] Session option to reboot, shutdown etc - [x] Multi keyboard layout support + switch widget -- [x] Calendar widget (not interactive) - [x] Rofi application launcher and window switcher -- [x] Volume / Brightness switcher -- [X] Dock +- [x] Volume / Brightness control widget +- [X] Configurable Dock - [x] Systray +- [x] GPU/CPU/RAM Temperature, Usage and Clock widget +- [x] Full audio device selector +- [x] Easy to configure dots +- [x] Interactive notifications -Some stuff planned for the future +#### Some stuff planned for the future - [ ] Calendar OSD -- [ ] GPU/CPU/RAM etc Temparature and Usage widget -- [ ] Extended volume and microphone control - [ ] More bugs - [ ] I3 like layout / manual tiling -I've added various widgets you can choose or remove how you like it. +
-__Including__:
-Battery, Network (Wifi, Ethernet), Bluetooth, Volume, Keyboardlayout, Date (with Calendar), Time, Session options, Taglist, Tasklist, Layoutswitcher. +There are many widgets to choose from + +**Widget List**: + +- Battery +- Network (Wifi, Ethernet) +- Bluetooth +- Volume +- Keyboardlayout +- Date +- Time +- Session options +- Taglist +- Tasklist +- Layoutswitcher +- GPU/CPU/RAM Temperature/Usage and Clock speed. + +## Gallery + +--- +>![desktop](assets/desktop.png) +> +>Entire Desktop with two terminal open + +>![lockscreen](assets/lockscreen.png) +> +>Lockscreen + +>![EntireScreen_VolumeOSD](assets/EntireScreen_VolumeOSD.png) +> +>Volume OSD (Backlight looks similar) + +>![DeviceChooser](assets/DeviceChooser.png) +> +>Switch In/Output devices easily + +>![Notification1](assets/Notification1.png) +> +>Spotify example notification with working media control + +>![TopLeftBar](assets/TopLeftBar.png) +> +>Top Left bar closeup + +>![TopCenter](assets/TopCenter.png) +> +>Top Center bar closeup + +>![TopRight](assets/TopRight.png) +> +>Top Right bar closeup + +>![dock](assets/dock.png) +> +>Dock closeup ## Known bugs diff --git a/assets/DeviceChooser.png b/assets/DeviceChooser.png new file mode 100644 index 0000000..913df96 Binary files /dev/null and b/assets/DeviceChooser.png differ diff --git a/assets/EntireScreen_VolumeOSD.png b/assets/EntireScreen_VolumeOSD.png new file mode 100644 index 0000000..8d5ebc0 Binary files /dev/null and b/assets/EntireScreen_VolumeOSD.png differ diff --git a/assets/Notification1.png b/assets/Notification1.png new file mode 100644 index 0000000..0492472 Binary files /dev/null and b/assets/Notification1.png differ diff --git a/assets/TopCenter.png b/assets/TopCenter.png new file mode 100644 index 0000000..ffd15c0 Binary files /dev/null and b/assets/TopCenter.png differ diff --git a/assets/TopLeftBar.png b/assets/TopLeftBar.png new file mode 100644 index 0000000..75778fb Binary files /dev/null and b/assets/TopLeftBar.png differ diff --git a/assets/TopRight.png b/assets/TopRight.png new file mode 100644 index 0000000..de9bdd5 Binary files /dev/null and b/assets/TopRight.png differ diff --git a/desktop.png b/assets/desktop.png similarity index 100% rename from desktop.png rename to assets/desktop.png diff --git a/assets/dock.png b/assets/dock.png new file mode 100644 index 0000000..ed3c8cf Binary files /dev/null and b/assets/dock.png differ diff --git a/lockscreen.png b/assets/lockscreen.png similarity index 100% rename from lockscreen.png rename to assets/lockscreen.png diff --git a/assets/neofetch.png b/assets/neofetch.png new file mode 100644 index 0000000..d0222eb Binary files /dev/null and b/assets/neofetch.png differ diff --git a/awesome/crylia_bar/center_bar.lua b/awesome/crylia_bar/center_bar.lua index c986b0f..3da39a9 100644 --- a/awesome/crylia_bar/center_bar.lua +++ b/awesome/crylia_bar/center_bar.lua @@ -38,7 +38,7 @@ return function(s, widgets) { widget, left = dpi(6), - right = dpi(3), + right = dpi(6), top = dpi(6), bottom = dpi(6), widget = wibox.container.margin diff --git a/awesome/crylia_bar/dock.lua b/awesome/crylia_bar/dock.lua index 089ce1c..498e90a 100644 --- a/awesome/crylia_bar/dock.lua +++ b/awesome/crylia_bar/dock.lua @@ -10,12 +10,12 @@ local wibox = require("wibox") return function(screen, programs) - local function create_dock_element(class, program, name, is_steam, size) + local function create_dock_element(class, program, name, user_icon, is_steam, size) if program == nil or class == nil then return end is_steam = is_steam or false - + user_icon = user_icon or nil local dock_element = wibox.widget { { { @@ -23,9 +23,9 @@ return function(screen, programs) resize = true, forced_width = size, forced_height = size, - image = Get_icon(user_vars.icon_theme, nil, program, class, is_steam), + image = user_icon or Get_icon(user_vars.icon_theme, nil, program, class, is_steam), widget = wibox.widget.imagebox, - id = "icon" + id = "icon", }, margins = dpi(5), widget = wibox.container.margin, @@ -104,7 +104,7 @@ return function(screen, programs) local dock_elements = { layout = wibox.layout.fixed.horizontal } for i, p in ipairs(pr) do - dock_elements[i] = create_dock_element(p[1], p[2], p[3], p[4], user_vars.dock_icon_size) + dock_elements[i] = create_dock_element(p[1], p[2], p[3], p[4], p[5], user_vars.dock_icon_size) end return dock_elements @@ -181,22 +181,14 @@ return function(screen, programs) } local function check_for_dock_hide(s) - local naughty = require("naughty") if #s.selected_tag:clients() < 1 then dock.visible = true return end if s == mouse.screen then - --[[ if mouse.current_widget then - if tostring(mouse.current_widget):match("fake") then - dock.visible = true - return - end - end ]] local visible = false for j, c in ipairs(s.selected_tag:clients()) do - --naughty.notify({ title = tostring(c.class) }) if c.maximized or c.fullscreen then dock.visible = false return @@ -209,10 +201,6 @@ return function(screen, programs) else dock.visible = true end - --[[ if visible then - dock.visible = visible - return - end ]] end else dock.visible = false diff --git a/awesome/crylia_bar/init.lua b/awesome/crylia_bar/init.lua index f633f35..c244c05 100644 --- a/awesome/crylia_bar/init.lua +++ b/awesome/crylia_bar/init.lua @@ -23,29 +23,30 @@ awful.screen.connect_for_each_screen( require("src.modules.volume_osd")(s) require("src.modules.brightness_osd")(s) require("src.modules.titlebar") + require("src.modules.volume_controller")(s) -- Widgets - s.battery = require("src.widgets.battery")() - s.network = require("src.widgets.network")() - s.audio = require("src.widgets.audio")() + --s.battery = require("src.widgets.battery")() + s.audio = require("src.widgets.audio")(s) s.date = require("src.widgets.date")() s.clock = require("src.widgets.clock")() - s.bluetooth = require("src.widgets.bluetooth")() + --s.bluetooth = require("src.widgets.bluetooth")() s.layoutlist = require("src.widgets.layout_list")() s.powerbutton = require("src.widgets.power")() s.kblayout = require("src.widgets.kblayout")(s) s.taglist = require("src.widgets.taglist")(s) s.tasklist = require("src.widgets.tasklist")(s) - s.systray = require("src.widgets.systray")(s) - s.cpu_usage = require("src.widgets.cpu_info")("usage") - s.cpu_temp = require("src.widgets.cpu_info")("temp") - s.cpu_freq = require("src.widgets.cpu_info")("freq", "average") - s.ram_info = require("src.widgets.ram_info")() - s.gpu_usage = require("src.widgets.gpu_info")("usage") - s.gpu_temp = require("src.widgets.gpu_info")("temp") + --s.cpu_freq = require("src.widgets.cpu_info")("freq", "average") + -- Add more of these if statements if you want to change -- the modules/widgets per screen. if s.index == 1 then + s.systray = require("src.widgets.systray")(s) + s.cpu_usage = require("src.widgets.cpu_info")("usage") + s.cpu_temp = require("src.widgets.cpu_info")("temp") + s.gpu_usage = require("src.widgets.gpu_info")("usage") + s.gpu_temp = require("src.widgets.gpu_info")("temp") + require("crylia_bar.left_bar")(s, { s.layoutlist, s.systray, s.taglist }) require("crylia_bar.center_bar")(s, { s.tasklist }) require("crylia_bar.right_bar")(s, { s.gpu_usage, s.gpu_temp, s.cpu_usage, s.cpu_temp, s.audio, s.kblayout, s.date, s.clock, s.powerbutton }) @@ -53,6 +54,9 @@ awful.screen.connect_for_each_screen( end if s.index == 2 then + s.network = require("src.widgets.network")() + s.ram_info = require("src.widgets.ram_info")() + require("crylia_bar.left_bar")(s, { s.layoutlist, s.taglist }) require("crylia_bar.center_bar")(s, { s.tasklist }) require("crylia_bar.right_bar")(s, { s.ram_info, s.audio, s.kblayout, s.network, s.date, s.clock, s.powerbutton }) diff --git a/awesome/mappings/bind_to_tags.lua b/awesome/mappings/bind_to_tags.lua index d3ad616..ccba2c7 100644 --- a/awesome/mappings/bind_to_tags.lua +++ b/awesome/mappings/bind_to_tags.lua @@ -5,63 +5,63 @@ local globalkeys = require("../mappings/global_keys") local modkey = user_vars.modkey for i = 1, 9 do - globalkeys = gears.table.join(globalkeys, + globalkeys = gears.table.join(globalkeys, - -- View tag only - awful.key( - { modkey }, - "#" .. i + 9, - function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - tag:view_only() - end - client.emit_signal("tag::switched") - end, - { description = "View Tag " .. i, group = "Tag" } - ), - -- Brings the window over without chaning the tag, reverts automatically on tag change - awful.key( - { modkey, "Control" }, - "#" .. i + 9, - function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, - { description = "Toggle Tag " .. i, group = "Tag" } - ), - -- Brings the window over without chaning the tag, reverts automatically on tag change - awful.key( - { modkey, "Shift" }, - "#" .. i + 9, - function() - local screen = awful.screen.focused() - if client.focus then - local tag = screen.tags[i] - if tag then - client.focus:move_to_tag(tag) - end - end - end, - { description = "Move focused client on tag " .. i, group = "Tag" } - ), - -- Brings the window over without chaning the tag, reverts automatically on tag change - awful.key( - { modkey, "Control", "Shift" }, - "#" .. i + 9, - function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, - { description = "Move focused client on tag " .. i, group = "Tag" } - ) + -- View tag only + awful.key( + { modkey }, + "#" .. i + 9, + function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + client.emit_signal("tag::switched") + end, + { description = "View Tag " .. i, group = "Tag" } + ), + -- Brings the window over without chaning the tag, reverts automatically on tag change + awful.key( + { modkey, "Control" }, + "#" .. i + 9, + function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + { description = "Toggle Tag " .. i, group = "Tag" } + ), + -- Brings the window over without chaning the tag, reverts automatically on tag change + awful.key( + { modkey, "Shift" }, + "#" .. i + 9, + function() + local screen = awful.screen.focused() + if client.focus then + local tag = screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, + { description = "Move focused client on tag " .. i, group = "Tag" } + ), + -- Brings the window over without chaning the tag, reverts automatically on tag change + awful.key( + { modkey, "Control", "Shift" }, + "#" .. i + 9, + function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + { description = "Move focused client on tag " .. i, group = "Tag" } ) + ) end root.keys(globalkeys) diff --git a/awesome/mappings/client_buttons.lua b/awesome/mappings/client_buttons.lua index a539193..dcbb7e9 100644 --- a/awesome/mappings/client_buttons.lua +++ b/awesome/mappings/client_buttons.lua @@ -5,15 +5,15 @@ local gears = require("gears") local modkey = user_vars.modkey return gears.table.join( - awful.button({}, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - end), - awful.button({ modkey }, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.move(c) - end), - awful.button({ modkey }, 3, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.resize(c) - end) + awful.button({}, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + end), + awful.button({ modkey }, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({ modkey }, 3, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.resize(c) + end) ) diff --git a/awesome/mappings/client_keys.lua b/awesome/mappings/client_keys.lua index 4945915..274f1fe 100644 --- a/awesome/mappings/client_keys.lua +++ b/awesome/mappings/client_keys.lua @@ -5,53 +5,53 @@ local gears = require("gears") local modkey = user_vars.modkey return gears.table.join( - awful.key( - { modkey }, - "#41", - function(c) - c.fullscreen = not c.fullscreen - c:raise() - end, - { description = "Toggle fullscreen", group = "Client" } - ), - awful.key( - { modkey }, - "#24", - function(c) - c:kill() - end, - { description = "Close focused client", group = "Client" } - ), - awful.key( - { modkey }, - "#42", - awful.client.floating.toggle, - { description = "Toggle floating window", group = "Client" } - ), - awful.key( - { modkey }, - "#58", - function(c) - c.maximized = not c.maximized - c:raise() - end, - { description = "(un)maximize", group = "Client" } - ), - awful.key( - { modkey }, - "#57", - function(c) - if c == client.focus then - c.minimized = true - else - c.minimized = false - if not c:isvisible() and c.first_tag then - c.first_tag:view_only() - end - c:emit_signal('request::activate') - c:raise() - end - end, - { description = "(un)hide", group = "Client" } - ) + awful.key( + { modkey }, + "#41", + function(c) + c.fullscreen = not c.fullscreen + c:raise() + end, + { description = "Toggle fullscreen", group = "Client" } + ), + awful.key( + { modkey }, + "#24", + function(c) + c:kill() + end, + { description = "Close focused client", group = "Client" } + ), + awful.key( + { modkey }, + "#42", + awful.client.floating.toggle, + { description = "Toggle floating window", group = "Client" } + ), + awful.key( + { modkey }, + "#58", + function(c) + c.maximized = not c.maximized + c:raise() + end, + { description = "(un)maximize", group = "Client" } + ), + awful.key( + { modkey }, + "#57", + function(c) + if c == client.focus then + c.minimized = true + else + c.minimized = false + if not c:isvisible() and c.first_tag then + c.first_tag:view_only() + end + c:emit_signal('request::activate') + c:raise() + end + end, + { description = "(un)hide", group = "Client" } + ) ) diff --git a/awesome/mappings/global_buttons.lua b/awesome/mappings/global_buttons.lua index f7ebd39..023a309 100644 --- a/awesome/mappings/global_buttons.lua +++ b/awesome/mappings/global_buttons.lua @@ -3,6 +3,6 @@ local gears = require("gears") local awful = require("awful") root.buttons = gears.table.join( - awful.button({}, 4, awful.tag.viewnext), - awful.button({}, 5, awful.tag.viewprev) + awful.button({}, 4, awful.tag.viewnext), + awful.button({}, 5, awful.tag.viewprev) ) diff --git a/awesome/mappings/global_keys.lua b/awesome/mappings/global_keys.lua index f2493ba..041e07e 100644 --- a/awesome/mappings/global_keys.lua +++ b/awesome/mappings/global_keys.lua @@ -7,378 +7,375 @@ local ruled = require("ruled") local modkey = user_vars.modkey return gears.table.join( - awful.key( - { modkey }, - "#39", - hotkeys_popup.show_help, - { description = "Cheat sheet", group = "Awesome" } - ), - -- Tag browsing - awful.key( - { modkey }, - "#113", - awful.tag.viewprev, - { description = "View previous tag", group = "Tag" } - ), - awful.key( - { modkey }, - "#114", - awful.tag.viewnext, - { description = "View next tag", group = "Tag" } - ), - awful.key( - { modkey }, - "#66", - awful.tag.history.restore, - { description = "Go back to last tag", group = "Tag" } - ), - awful.key( - { modkey }, - "#44", - function() - awful.client.focus.byidx(1) - end, - { description = "Focus next client by index", group = "Client" } - ), - awful.key( - { modkey }, - "#45", - function() - awful.client.focus.byidx(-1) - end, - { description = "Focus previous client by index", group = "Client" } - ), - awful.key( - { modkey }, - "#25", - function() - user_vars.main_menu:show() - end, - { description = "Show context menu", group = "Awesome" } - ), - awful.key( - { modkey, "Shift" }, - "#44", - function() - awful.client.swap.byidx(1) - end, - { description = "Swap with next client by index", group = "Client" } - ), - awful.key( - { modkey, "Shift" }, - "#45", - function() - awful.client.swap.byidx(-1) - end, - { description = "Swap with previous client by index", group = "Client" } - ), - awful.key( - { modkey, "Control" }, - "#44", - function() - awful.screen.focus_relative(1) - end, - { description = "Focus the next screen", group = "Screen" } - ), - awful.key( - { modkey, "Control" }, - "#45", - function() - awful.screen.focus_relative(-1) - end, - { description = "Focus the previous screen", group = "Screen" } - ), - awful.key( - { modkey }, - "#30", - awful.client.urgent.jumpto, - { description = "Jump to urgent client", group = "Client" } - ), - awful.key( - { modkey }, - "#36", - function() - awful.spawn(user_vars.terminal) - end, - { description = "Open terminal", group = "Applications" } - ), - awful.key( - { modkey, "Control" }, - "#27", - awesome.restart, - { description = "Reload awesome", group = "Awesome" } - ), - awful.key( - { modkey }, - "#46", - function() - awful.tag.incmwfact(0.05) - end, - { description = "Increase client width", group = "Layout" } - ), - awful.key( - { modkey }, - "#43", - function() - awful.tag.incmwfact(-0.05) - end, - { description = "Decrease client width", group = "Layout" } - ), - awful.key( - { modkey, "Control" }, - "#43", - function() - awful.tag.incncol(1, nil, true) - end, - { description = "Increase the number of columns", group = "Layout" } - ), - awful.key( - { modkey, "Control" }, - "#46", - function() - awful.tag.incncol(-1, nil, true) - end, - { description = "Decrease the number of columns", group = "Layout" } - ), - awful.key( - { modkey, "Shift" }, - "#65", - function() - awful.layout.inc(-1) - end, - { description = "Select previous layout", group = "Layout" } - ), - awful.key( - { modkey, "Shift" }, - "#36", - function() - awful.layout.inc(1) - end, - { description = "Select next layout", group = "Layout" } - ), - awful.key( - { modkey }, - "#40", - function() - awful.spawn("rofi -show drun -theme ~/.config/rofi/rofi.rasi") - end, - { descripton = "Application launcher", group = "Application" } - ), - awful.key( - { modkey }, - "#23", - function() - awful.spawn("rofi -show window -theme ~/.config/rofi/window.rasi") - end, - { descripton = "Client switcher (alt+tab)", group = "Application" } - ), - awful.key( - { "Mod1" }, - "#23", - function() - awful.spawn("rofi -show window -theme ~/.config/rofi/window.rasi") - end, - { descripton = "Client switcher (alt+tab)", group = "Application" } - ), - awful.key( - { modkey }, - "#26", - function() - awful.spawn(user_vars.file_manager) - end, - { descripton = "Open file manager", group = "System" } - ), - awful.key( - { modkey, "Shift" }, - "#26", - function() - awesome.emit_signal("module::powermenu:show") - end, - { descripton = "Session options", group = "System" } - ), - awful.key( - {}, - "#107", - function() - awful.spawn(user_vars.screenshot_program) - end, - { description = "Screenshot", group = "Applications" } - ), - awful.key( - {}, - "XF86AudioLowerVolume", - function(c) - awful.spawn.easy_async_with_shell("pactl set-sink-volume @DEFAULT_SINK@ -2%", function() - awesome.emit_signal("widget::volume") - awesome.emit_signal("module::volume_osd:show", true) - awesome.emit_signal("module::slider:update") - awesome.emit_signal("widget::volume_osd:rerun") - end) - end, - { description = "Lower volume", group = "System" } - ), - awful.key( - {}, - "XF86AudioRaiseVolume", - function(c) - awful.spawn.easy_async_with_shell("pactl set-sink-volume @DEFAULT_SINK@ +2%", function() - awesome.emit_signal("widget::volume") - awesome.emit_signal("module::volume_osd:show", true) - awesome.emit_signal("module::slider:update") - awesome.emit_signal("widget::volume_osd:rerun") - end) - end, - { description = "Increase volume", group = "System" } - ), - awful.key( - {}, - "XF86AudioMute", - function(c) - awful.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle") - awesome.emit_signal("widget::volume") - awesome.emit_signal("module::volume_osd:show", true) - awesome.emit_signal("module::slider:update") - awesome.emit_signal("widget::volume_osd:rerun") - end, - { description = "Mute volume", group = "System" } - ), - awful.key( - {}, - "XF86MonBrightnessUp", - function(c) - --awful.spawn("xbacklight -time 100 -inc 10%+") - awful.spawn.easy_async_with_shell( - "pkexec xfpm-power-backlight-helper --get-brightness", - function(stdout) - awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. tostring(tonumber(stdout) + BACKLIGHT_SEPS), function(stdou2) + awful.key( + { modkey }, + "#39", + hotkeys_popup.show_help, + { description = "Cheat sheet", group = "Awesome" } + ), + -- Tag browsing + awful.key( + { modkey }, + "#113", + awful.tag.viewprev, + { description = "View previous tag", group = "Tag" } + ), + awful.key( + { modkey }, + "#114", + awful.tag.viewnext, + { description = "View next tag", group = "Tag" } + ), + awful.key( + { modkey }, + "#66", + awful.tag.history.restore, + { description = "Go back to last tag", group = "Tag" } + ), + awful.key( + { modkey }, + "#44", + function() + awful.client.focus.byidx(1) + end, + { description = "Focus next client by index", group = "Client" } + ), + awful.key( + { modkey }, + "#45", + function() + awful.client.focus.byidx(-1) + end, + { description = "Focus previous client by index", group = "Client" } + ), + awful.key( + { modkey }, + "#25", + function() + user_vars.main_menu:show() + end, + { description = "Show context menu", group = "Awesome" } + ), + awful.key( + { modkey, "Shift" }, + "#44", + function() + awful.client.swap.byidx(1) + end, + { description = "Swap with next client by index", group = "Client" } + ), + awful.key( + { modkey, "Shift" }, + "#45", + function() + awful.client.swap.byidx(-1) + end, + { description = "Swap with previous client by index", group = "Client" } + ), + awful.key( + { modkey, "Control" }, + "#44", + function() + awful.screen.focus_relative(1) + end, + { description = "Focus the next screen", group = "Screen" } + ), + awful.key( + { modkey, "Control" }, + "#45", + function() + awful.screen.focus_relative(-1) + end, + { description = "Focus the previous screen", group = "Screen" } + ), + awful.key( + { modkey }, + "#30", + awful.client.urgent.jumpto, + { description = "Jump to urgent client", group = "Client" } + ), + awful.key( + { modkey }, + "#36", + function() + awful.spawn(user_vars.terminal) + end, + { description = "Open terminal", group = "Applications" } + ), + awful.key( + { modkey, "Control" }, + "#27", + awesome.restart, + { description = "Reload awesome", group = "Awesome" } + ), + awful.key( + { modkey }, + "#46", + function() + awful.tag.incmwfact(0.05) + end, + { description = "Increase client width", group = "Layout" } + ), + awful.key( + { modkey }, + "#43", + function() + awful.tag.incmwfact(-0.05) + end, + { description = "Decrease client width", group = "Layout" } + ), + awful.key( + { modkey, "Control" }, + "#43", + function() + awful.tag.incncol(1, nil, true) + end, + { description = "Increase the number of columns", group = "Layout" } + ), + awful.key( + { modkey, "Control" }, + "#46", + function() + awful.tag.incncol(-1, nil, true) + end, + { description = "Decrease the number of columns", group = "Layout" } + ), + awful.key( + { modkey, "Shift" }, + "#65", + function() + awful.layout.inc(-1) + end, + { description = "Select previous layout", group = "Layout" } + ), + awful.key( + { modkey, "Shift" }, + "#36", + function() + awful.layout.inc(1) + end, + { description = "Select next layout", group = "Layout" } + ), + awful.key( + { modkey }, + "#40", + function() + awful.spawn("rofi -show drun -theme ~/.config/rofi/rofi.rasi") + end, + { descripton = "Application launcher", group = "Application" } + ), + awful.key( + { modkey }, + "#23", + function() + awful.spawn("rofi -show window -theme ~/.config/rofi/window.rasi") + end, + { descripton = "Client switcher (alt+tab)", group = "Application" } + ), + awful.key( + { "Mod1" }, + "#23", + function() + awful.spawn("rofi -show window -theme ~/.config/rofi/window.rasi") + end, + { descripton = "Client switcher (alt+tab)", group = "Application" } + ), + awful.key( + { modkey }, + "#26", + function() + awful.spawn(user_vars.file_manager) + end, + { descripton = "Open file manager", group = "System" } + ), + awful.key( + { modkey, "Shift" }, + "#26", + function() + awesome.emit_signal("module::powermenu:show") + end, + { descripton = "Session options", group = "System" } + ), + awful.key( + {}, + "#107", + function() + awful.spawn(user_vars.screenshot_program) + end, + { description = "Screenshot", group = "Applications" } + ), + awful.key( + {}, + "XF86AudioLowerVolume", + function(c) + awful.spawn.easy_async_with_shell("pactl set-sink-volume @DEFAULT_SINK@ -2%", function() + awesome.emit_signal("module::volume_osd:show", true) + awesome.emit_signal("module::slider:update") + awesome.emit_signal("widget::volume_osd:rerun") + end) + end, + { description = "Lower volume", group = "System" } + ), + awful.key( + {}, + "XF86AudioRaiseVolume", + function(c) + awful.spawn.easy_async_with_shell("pactl set-sink-volume @DEFAULT_SINK@ +2%", function() + awesome.emit_signal("module::volume_osd:show", true) + awesome.emit_signal("module::slider:update") + awesome.emit_signal("widget::volume_osd:rerun") + end) + end, + { description = "Increase volume", group = "System" } + ), + awful.key( + {}, + "XF86AudioMute", + function(c) + awful.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle") + awesome.emit_signal("module::volume_osd:show", true) + awesome.emit_signal("module::slider:update") + awesome.emit_signal("widget::volume_osd:rerun") + end, + { description = "Mute volume", group = "System" } + ), + awful.key( + {}, + "XF86MonBrightnessUp", + function(c) + --awful.spawn("xbacklight -time 100 -inc 10%+") + awful.spawn.easy_async_with_shell( + "pkexec xfpm-power-backlight-helper --get-brightness", + function(stdout) + awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. tostring(tonumber(stdout) + BACKLIGHT_SEPS), function(stdou2) - end) - awesome.emit_signal("module::brightness_osd:show", true) - awesome.emit_signal("module::brightness_slider:update") - awesome.emit_signal("widget::brightness_osd:rerun") - end - ) - end, - { description = "Raise backlight brightness", group = "System" } - ), - awful.key( - {}, - "XF86MonBrightnessDown", - function(c) - awful.spawn.easy_async_with_shell( - "pkexec xfpm-power-backlight-helper --get-brightness", - function(stdout) - awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. tostring(tonumber(stdout) - BACKLIGHT_SEPS), function(stdout2) + end) + awesome.emit_signal("module::brightness_osd:show", true) + awesome.emit_signal("module::brightness_slider:update") + awesome.emit_signal("widget::brightness_osd:rerun") + end + ) + end, + { description = "Raise backlight brightness", group = "System" } + ), + awful.key( + {}, + "XF86MonBrightnessDown", + function(c) + awful.spawn.easy_async_with_shell( + "pkexec xfpm-power-backlight-helper --get-brightness", + function(stdout) + awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. tostring(tonumber(stdout) - BACKLIGHT_SEPS), function(stdout2) - end) - awesome.emit_signal("module::brightness_osd:show", true) - awesome.emit_signal("module::brightness_slider:update") - awesome.emit_signal("widget::brightness_osd:rerun") - end - ) - end, - { description = "Lower backlight brightness", group = "System" } - ), - awful.key( - {}, - "XF86AudioPlay", - function(c) - awful.spawn("playerctl play-pause") - end, - { description = "Play / Pause audio", group = "System" } - ), - awful.key( - {}, - "XF86AudioNext", - function(c) - awful.spawn("playerctl next") - end, - { description = "Play / Pause audio", group = "System" } - ), - awful.key( - {}, - "XF86AudioPrev", - function(c) - awful.spawn("playerctl previous") - end, - { description = "Play / Pause audio", group = "System" } - ), - awful.key( - { modkey }, - "#65", - function() - awesome.emit_signal("kblayout::toggle") - end, - { description = "Toggle keyboard layout", group = "System" } - ), - awful.key( - { modkey }, - "#22", - function() - awful.spawn.easy_async_with_shell( - [[xprop | grep WM_CLASS | awk '{gsub(/"/, "", $4); print $4}']], - function(stdout) - if stdout then - ruled.client.append_rule { - rule = { class = stdout:gsub("\n", "") }, - properties = { - floating = true - }, - } - awful.spawn.easy_async_with_shell( - "cat ~/.config/awesome/src/assets/rules.txt", - function(stdout2) - for class in stdout2:gmatch("%a+") do - if class:match(stdout:gsub("\n", "")) then - return - end - end - awful.spawn.with_shell("echo -n '" .. stdout:gsub("\n", "") .. ";' >> ~/.config/awesome/src/assets/rules.txt") - local c = mouse.screen.selected_tag:clients() - for j, client in ipairs(c) do - if client.class:match(stdout:gsub("\n", "")) then - client.floating = true - end - end - end - ) - end - end - ) + end) + awesome.emit_signal("module::brightness_osd:show", true) + awesome.emit_signal("module::brightness_slider:update") + awesome.emit_signal("widget::brightness_osd:rerun") + end + ) + end, + { description = "Lower backlight brightness", group = "System" } + ), + awful.key( + {}, + "XF86AudioPlay", + function(c) + awful.spawn("playerctl play-pause") + end, + { description = "Play / Pause audio", group = "System" } + ), + awful.key( + {}, + "XF86AudioNext", + function(c) + awful.spawn("playerctl next") + end, + { description = "Play / Pause audio", group = "System" } + ), + awful.key( + {}, + "XF86AudioPrev", + function(c) + awful.spawn("playerctl previous") + end, + { description = "Play / Pause audio", group = "System" } + ), + awful.key( + { modkey }, + "#65", + function() + awesome.emit_signal("kblayout::toggle") + end, + { description = "Toggle keyboard layout", group = "System" } + ), + awful.key( + { modkey }, + "#22", + function() + awful.spawn.easy_async_with_shell( + [[xprop | grep WM_CLASS | awk '{gsub(/"/, "", $4); print $4}']], + function(stdout) + if stdout then + ruled.client.append_rule { + rule = { class = stdout:gsub("\n", "") }, + properties = { + floating = true + }, + } + awful.spawn.easy_async_with_shell( + "cat ~/.config/awesome/src/assets/rules.txt", + function(stdout2) + for class in stdout2:gmatch("%a+") do + if class:match(stdout:gsub("\n", "")) then + return + end + end + awful.spawn.with_shell("echo -n '" .. stdout:gsub("\n", "") .. ";' >> ~/.config/awesome/src/assets/rules.txt") + local c = mouse.screen.selected_tag:clients() + for j, client in ipairs(c) do + if client.class:match(stdout:gsub("\n", "")) then + client.floating = true + end + end end - ), - awful.key( - { modkey, "Shift" }, - "#22", - function() - awful.spawn.easy_async_with_shell( - [[xprop | grep WM_CLASS | awk '{gsub(/"/, "", $4); print $4}']], - function(stdout) - if stdout then - ruled.client.append_rule { - rule = { class = stdout:gsub("\n", "") }, - properties = { - floating = false - }, - } - awful.spawn.easy_async_with_shell( - [[ + ) + end + end + ) + end + ), + awful.key( + { modkey, "Shift" }, + "#22", + function() + awful.spawn.easy_async_with_shell( + [[xprop | grep WM_CLASS | awk '{gsub(/"/, "", $4); print $4}']], + function(stdout) + if stdout then + ruled.client.append_rule { + rule = { class = stdout:gsub("\n", "") }, + properties = { + floating = false + }, + } + awful.spawn.easy_async_with_shell( + [[ REMOVE="]] .. stdout:gsub("\n", "") .. [[;" STR=$(cat ~/.config/awesome/src/assets/rules.txt) echo -n ${STR//$REMOVE/} > ~/.config/awesome/src/assets/rules.txt ]], - function(stdout2) - local c = mouse.screen.selected_tag:clients() - for j, client in ipairs(c) do - if client.class:match(stdout:gsub("\n", "")) then - client.floating = false - end - end - end - ) - end - end - ) + function(stdout2) + local c = mouse.screen.selected_tag:clients() + for j, client in ipairs(c) do + if client.class:match(stdout:gsub("\n", "")) then + client.floating = false + end + end end + ) + end + end ) + end + ) ) diff --git a/awesome/rc.lua b/awesome/rc.lua index 686fa04..0a1132f 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -10,9 +10,10 @@ require("src.theme.user_variables") require("src.theme.init") require("src.core.error_handling") -require("src.core.rules") require("src.core.signals") +require("src.core.notifications") +require("src.core.rules") require("mappings.global_buttons") require("mappings.bind_to_tags") require("crylia_bar.init") ---require("src.tools.auto_starter")(user_vars.autostart) +require("src.tools.auto_starter")(user_vars.autostart) diff --git a/awesome/src/assets/icons/notifications/play-pause.svg b/awesome/src/assets/icons/notifications/play-pause.svg new file mode 100644 index 0000000..5b58b8a --- /dev/null +++ b/awesome/src/assets/icons/notifications/play-pause.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/awesome/src/assets/icons/notifications/skip-next.svg b/awesome/src/assets/icons/notifications/skip-next.svg new file mode 100644 index 0000000..2d3a46e --- /dev/null +++ b/awesome/src/assets/icons/notifications/skip-next.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/awesome/src/assets/icons/notifications/skip-prev.svg b/awesome/src/assets/icons/notifications/skip-prev.svg new file mode 100644 index 0000000..62dc70f --- /dev/null +++ b/awesome/src/assets/icons/notifications/skip-prev.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/awesome/src/assets/layout/cornerne.svg b/awesome/src/assets/layout/cornerne.svg new file mode 100644 index 0000000..faba2e6 --- /dev/null +++ b/awesome/src/assets/layout/cornerne.svg @@ -0,0 +1,14 @@ + + + Layer 1 + + + + + + + + + + + \ No newline at end of file diff --git a/awesome/src/assets/layout/cornernw.svg b/awesome/src/assets/layout/cornernw.svg new file mode 100644 index 0000000..dc57d80 --- /dev/null +++ b/awesome/src/assets/layout/cornernw.svg @@ -0,0 +1,12 @@ + + + Layer 1 + + + + + + + + + \ No newline at end of file diff --git a/awesome/src/assets/layout/cornerse.svg b/awesome/src/assets/layout/cornerse.svg new file mode 100644 index 0000000..3a977a2 --- /dev/null +++ b/awesome/src/assets/layout/cornerse.svg @@ -0,0 +1,14 @@ + + + Layer 1 + + + + + + + + + + + \ No newline at end of file diff --git a/awesome/src/assets/layout/cornersw.svg b/awesome/src/assets/layout/cornersw.svg new file mode 100644 index 0000000..b68e050 --- /dev/null +++ b/awesome/src/assets/layout/cornersw.svg @@ -0,0 +1,14 @@ + + + Layer 1 + + + + + + + + + + + \ No newline at end of file diff --git a/awesome/src/assets/layout/fairh.svg b/awesome/src/assets/layout/fairh.svg new file mode 100644 index 0000000..37c0898 --- /dev/null +++ b/awesome/src/assets/layout/fairh.svg @@ -0,0 +1,14 @@ + + + Layer 1 + + + + + + + + + + + \ No newline at end of file diff --git a/awesome/src/assets/layout/fairv.svg b/awesome/src/assets/layout/fairv.svg new file mode 100644 index 0000000..d4f128d --- /dev/null +++ b/awesome/src/assets/layout/fairv.svg @@ -0,0 +1,12 @@ + + + Layer 1 + + + + + + + + + \ No newline at end of file diff --git a/awesome/src/assets/layout/floating.svg b/awesome/src/assets/layout/floating.svg index 5dcd846..82d2633 100644 --- a/awesome/src/assets/layout/floating.svg +++ b/awesome/src/assets/layout/floating.svg @@ -1,64 +1,12 @@ - - + + + Layer 1 + + + + + + + - - - - - image/svg+xml - - - - - - - - - + \ No newline at end of file diff --git a/awesome/src/assets/layout/tile.svg b/awesome/src/assets/layout/tile.svg index ea62c5d..08c780e 100644 --- a/awesome/src/assets/layout/tile.svg +++ b/awesome/src/assets/layout/tile.svg @@ -1,64 +1,9 @@ - - + + + Layer 1 + + + + - - - - - image/svg+xml - - - - - - - - diff --git a/awesome/src/assets/rules.txt b/awesome/src/assets/rules.txt index def3b54..9dba10f 100644 --- a/awesome/src/assets/rules.txt +++ b/awesome/src/assets/rules.txt @@ -1 +1 @@ -Lutris;Steam;Io.elementary.appcenter;Repoman;Com.github.donadigo.eddy;Sysmontask;join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=Gnome-calculator;Virt-manager;Gwe; \ No newline at end of file +Lutris;Steam;Io.elementary.appcenter;Repoman;Com.github.donadigo.eddy;Sysmontask;join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=Gnome-calculator;Virt-manager;Gwe;whatsdesk;Totem; \ No newline at end of file diff --git a/awesome/src/core/error_handling.lua b/awesome/src/core/error_handling.lua index 27f54a4..c1e0b25 100644 --- a/awesome/src/core/error_handling.lua +++ b/awesome/src/core/error_handling.lua @@ -4,30 +4,22 @@ -- Awesome Libs local naughty = require("naughty") -if awesome.startup_errors then - naughty.notify({ - preset = naughty.config.presets.critical, - title = "! Not so Awesome ERROR !", - text = awesome.startup_errors - }) -end - do - local in_error = false - awesome.connect_signal( - "debug::error", - function(err) - if in_error then - return - end - in_error = true + local in_error = false + awesome.connect_signal( + "debug::error", + function(err) + if in_error then + return + end + in_error = true - naughty.notify({ - preset = naughty.config.presets.critical, - title = "ERROR", - text = tostring(err) - }) - in_error = false - end - ) + naughty.notify({ + preset = naughty.config.presets.critical, + title = "ERROR", + text = tostring(err) + }) + in_error = false + end + ) end diff --git a/awesome/src/core/notifications.lua b/awesome/src/core/notifications.lua new file mode 100644 index 0000000..4781b54 --- /dev/null +++ b/awesome/src/core/notifications.lua @@ -0,0 +1,396 @@ +------------------------------- +-- The Notification defaults -- +------------------------------- + +-- Awesome Libs +local awful = require("awful") +local color = require("src.theme.colors") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local menubar = require('menubar') +local naughty = require("naughty") +local wibox = require("wibox") + +local icondir = awful.util.getdir("config") .. "src/assets/icons/notifications/" + +-- TODO: Figure out how to use hover effects without messing up the actions + +naughty.config.defaults.ontop = true +naughty.config.defaults.icon_size = dpi(80) +naughty.config.defaults.timeout = 3 +naughty.config.defaults.title = "System Notification" +naughty.config.defaults.margin = dpi(10) +naughty.config.defaults.position = "bottom_right" +naughty.config.defaults.shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(10)) +end +naughty.config.defaults.border_width = dpi(4) +naughty.config.defaults.border_color = color["Grey800"] +naughty.config.defaults.spacing = dpi(10) + +naughty.connect_signal( + 'request::icon', + function(n, context, hints) + if context ~= 'app_icon' then return end + local path = menubar.utils.lookup_icon(hints.app_icon) or + menubar.utils.lookup_icon(hints.app_icon:lower()) + if path then + n.icon = path + end +end +) + +naughty.connect_signal( + "request::display", + function(n) + + if n.urgency == "critical" then + n.title = string.format("%s", color["RedA200"], n.title) or "" + n.message = string.format("%s", color["Red200"], n.message) or "" + n.app_name = string.format("%s", color["RedA400"], n.app_name) or "" + n.bg = color["Grey900"] + else + n.title = string.format("%s", color["Pink200"], n.title) or "" + n.message = string.format("%s", "#ffffffaa", n.message) or "" + n.bg = color["Grey900"] + n.timeout = n.timeout or 3 + end + + local use_image = false + + if n.app_name == "Spotify" then + n.actions = { + naughty.action { + program = "Spotify", + id = "skip-prev", + icon = gears.color.recolor_image(icondir .. "skip-prev.svg", color["Cyan200"]), + }, + naughty.action { + program = "Spotify", + id = "play-pause", + icon = gears.color.recolor_image(icondir .. "play-pause.svg", color["Cyan200"]), + }, + naughty.action { + program = "Spotify", + id = "skip-next", + icon = gears.color.recolor_image(icondir .. "skip-next.svg", color["Cyan200"]), + }, + } + use_image = true + end + + local action_template_widget = {} + + if use_image then + action_template_widget = { + { + { + { + { + id = "icon_role", + widget = wibox.widget.imagebox + }, + id = "centered", + valign = "center", + halign = "center", + widget = wibox.container.place + }, + margins = dpi(5), + widget = wibox.container.margin + }, + forced_height = dpi(35), + forced_width = dpi(35), + fg = color["Cyan200"], + bg = color["Grey800"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(6)) + end, + widget = wibox.container.background, + id = "bgrnd" + }, + id = "mrgn", + top = dpi(10), + bottom = dpi(10), + widget = wibox.container.margin, + } + else + action_template_widget = { + { + { + { + { + id = "text_role", + font = "JetBrainsMono Nerd Font, Regular 12", + widget = wibox.widget.textbox + }, + id = "centered", + widget = wibox.container.place + }, + margins = dpi(5), + widget = wibox.container.margin + }, + fg = color["Green200"], + bg = color["Grey800"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(6)) + end, + widget = wibox.container.background, + id = "bgrnd" + }, + id = "mrgn", + top = dpi(10), + bottom = dpi(10), + widget = wibox.container.margin, + } + end + + local actions_template = wibox.widget { + notification = n, + base_layout = wibox.widget { + spacing = dpi(40), + layout = wibox.layout.fixed.horizontal + }, + widget_template = action_template_widget, + style = { + underline_normal = false, + underline_selected = true, + bg_normal = color["Grey100"], + bg_selected = color["Grey200"] + }, + widget = naughty.list.actions + } + + local w_template = wibox.widget { + { + { + { + { + { + { + { + { + markup = n.app_name or 'System Notification', + align = "center", + valign = "center", + widget = wibox.widget.textbox + }, + fg = color["Teal200"], + widget = wibox.container.background + }, + margins = dpi(10), + widget = wibox.container.margin + }, + nil, + { + { + { + { + { + font = user_vars.font.specify .. ", 10", + text = "✕", + align = "center", + valign = "center", + widget = wibox.widget.textbox + }, + start_angle = 4.71239, + thickness = dpi(2), + min_value = 0, + max_value = 360, + value = 360, + widget = wibox.container.arcchart, + id = "arc_chart" + }, + id = "background", + fg = color["Teal200"], + bg = color["Grey900"], + widget = wibox.container.background + }, + strategy = "exact", + width = dpi(20), + height = dpi(20), + widget = wibox.container.constraint, + id = "const" + }, + margins = dpi(10), + widget = wibox.container.margin, + id = "arc_margin" + }, + id = "arc_app_layout", + layout = wibox.layout.align.horizontal + }, + id = "arc_app_bg", + border_color = color["Grey800"], + border_width = dpi(2), + widget = wibox.container.background + }, + { + { + { + { + { + image = n.icon, + resize = true, + widget = wibox.widget.imagebox, + clip_shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 10) + end, + }, + width = naughty.config.defaults.icon_size, + height = naughty.config.defaults.icon_size, + strategy = "exact", + widget = wibox.container.constraint + }, + halign = "center", + valign = "top", + widget = wibox.container.place, + }, + left = dpi(20), + bottom = dpi(15), + top = dpi(15), + right = dpi(10), + widget = wibox.container.margin + }, + { + { + { + widget = naughty.widget.title, + align = "left" + }, + { + widget = naughty.widget.message, + align = "left" + }, + { + actions_template, + widget = wibox.container.place + }, + layout = wibox.layout.fixed.vertical + }, + left = dpi(10), + bottom = dpi(10), + top = dpi(10), + right = dpi(20), + widget = wibox.container.margin + }, + layout = wibox.layout.fixed.horizontal + }, + id = "widget_layout", + layout = wibox.layout.fixed.vertical + }, + id = "min_size", + strategy = "min", + width = dpi(100), + widget = wibox.container.constraint + }, + id = "max_size", + strategy = "max", + width = Theme.notification_max_width or dpi(500), + widget = wibox.container.constraint, + }, + id = "background", + bg = color["Grey900"], + border_color = color["Grey800"], + border_width = dpi(4), + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 4) + end, + widget = wibox.container.background + } + + local close = w_template.max_size.min_size.widget_layout.arc_app_bg.arc_app_layout.arc_margin.const.background + local arc = close.arc_chart + + local timeout = n.timeout + local remove_time = timeout + + if timeout ~= 0 then + arc.value = 360 + gears.timer { + timeout = 0.1, + call_now = true, + autostart = true, + callback = function() + arc.value = (remove_time - 0) / (timeout - 0) * 360 + remove_time = remove_time - 0.1 + end + } + end + + Hover_signal(close, color["Grey900"], color["Teal200"]) + + close:connect_signal( + "button::press", + function() + n:destroy() + end + ) + + w_template:connect_signal( + "button::press", + function(c, d, e, key) + if key == 3 then + n:destroy() + end + end + ) + + local box = naughty.layout.box { + notification = n, + timeout = 3, + type = "notification", + screen = awful.screen.focused(), + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 10) + end, + widget_template = w_template + } + + box.buttons = {} + n.buttons = {} +end +) + +naughty.connect_signal( + "destroyed", + function() + +end +) + +-- Test notification +--[[ naughty.notification { + app_name = "System Notification", + title = "A notification 2", + message = "This is very informative and overflowing", + icon = "/home/crylia/.config/awesome/src/assets/userpfp/crylia.png", + urgency = "normal", + timeout = 0, + actions = { + naughty.action { + name = "Accept", + }, + naughty.action { + name = "Refuse", + }, + naughty.action { + name = "Ignore", + }, + } +} ]] + +naughty.connect_signal( + "invoked", + function(_, action) + if action.program == "Spotify" then + if action.id == "skip-prev" then + awful.spawn("playerctl previous") + end + if action.id == "play-pause" then + awful.spawn("playerctl play-pause") + end + if action.id == "skip-next" then + awful.spawn("playerctl next") + end + end +end +) diff --git a/awesome/src/core/rules.lua b/awesome/src/core/rules.lua index 70a7546..8388f63 100644 --- a/awesome/src/core/rules.lua +++ b/awesome/src/core/rules.lua @@ -8,58 +8,58 @@ local beautiful = require("beautiful") local ruled = require("ruled") awful.rules.rules = { - { - rule = {}, - properties = { - border_width = beautiful.border_width, - border_color = beautiful.border_normal, - focus = awful.client.focus.filter, - raise = true, - keys = require("../../mappings/client_keys"), - buttons = require("../../mappings/client_buttons"), - screen = awful.screen.preferred, - placement = awful.placement.no_overlap + awful.placement.no_offscreen - } - }, - { - rule_any = { - instance = {}, - class = { - "Arandr", - "Lxappearance", - "kdeconnect.app", - "zoom", - "file-roller", - "File-roller" - }, - name = {}, - role = { - "AlarmWindow", - "ConfigManager", - "pop-up" - } - }, - properties = { floating = true, titlebars_enabled = true } - }, - { - id = "titlebar", - rule_any = { - type = { "normal", "dialog", "modal", "utility" } - }, - properties = { titlebars_enabled = true } + { + rule = {}, + properties = { + border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = require("../../mappings/client_keys"), + buttons = require("../../mappings/client_buttons"), + screen = awful.screen.preferred, + placement = awful.placement.no_overlap + awful.placement.no_offscreen } + }, + { + rule_any = { + instance = {}, + class = { + "Arandr", + "Lxappearance", + "kdeconnect.app", + "zoom", + "file-roller", + "File-roller" + }, + name = {}, + role = { + "AlarmWindow", + "ConfigManager", + "pop-up" + } + }, + properties = { floating = true, titlebars_enabled = true } + }, + { + id = "titlebar", + rule_any = { + type = { "normal", "dialog", "modal", "utility" } + }, + properties = { titlebars_enabled = true } + } } awful.spawn.easy_async_with_shell( - "cat ~/.config/awesome/src/assets/rules.txt", - function(stdout) - for class in stdout:gmatch("%a+") do - ruled.client.append_rule { - rule = { class = class }, - properties = { - floating = true - }, - } - end - end + "cat ~/.config/awesome/src/assets/rules.txt", + function(stdout) + for class in stdout:gmatch("%a+") do + ruled.client.append_rule { + rule = { class = class }, + properties = { + floating = true + }, + } + end +end ) diff --git a/awesome/src/core/signals.lua b/awesome/src/core/signals.lua index 5abf26e..aead15f 100644 --- a/awesome/src/core/signals.lua +++ b/awesome/src/core/signals.lua @@ -4,155 +4,155 @@ local beautiful = require("beautiful") local gears = require("gears") screen.connect_signal( - "added", - function() - awesome.restart() - end + "added", + function() + awesome.restart() +end ) screen.connect_signal( - "removed", - function() - awesome.restart() - end + "removed", + function() + awesome.restart() +end ) client.connect_signal( - "manage", - function(c) - if awesome.startup and not c.size_hints.user_porition and not c.size_hints.program_position then - awful.placement.no_offscreen(c) - end - c.shape = function(cr, width, height) - if c.fullscreen or c.maximized then - gears.shape.rectangle(cr, width, height) - else - gears.shape.rounded_rect(cr, width, height, 10) - end - end + "manage", + function(c) + if awesome.startup and not c.size_hints.user_porition and not c.size_hints.program_position then + awful.placement.no_offscreen(c) + end + c.shape = function(cr, width, height) + if c.fullscreen or c.maximized then + gears.shape.rectangle(cr, width, height) + else + gears.shape.rounded_rect(cr, width, height, 10) end + end +end ) client.connect_signal( - 'unmanage', - function(c) - if #awful.screen.focused().clients > 0 then - awful.screen.focused().clients[1]:emit_signal( - 'request::activate', - 'mouse_enter', - { - raise = true - } - ) - end - end + 'unmanage', + function(c) + if #awful.screen.focused().clients > 0 then + awful.screen.focused().clients[1]:emit_signal( + 'request::activate', + 'mouse_enter', + { + raise = true + } + ) + end +end ) client.connect_signal( - 'tag::switched', - function(c) - if #awful.screen.focused().clients > 0 then - awful.screen.focused().clients[1]:emit_signal( - 'request::activate', - 'mouse_enter', - { - raise = true - } - ) - end - end + 'tag::switched', + function(c) + if #awful.screen.focused().clients > 0 then + awful.screen.focused().clients[1]:emit_signal( + 'request::activate', + 'mouse_enter', + { + raise = true + } + ) + end +end ) -- Sloppy focus client.connect_signal("mouse::enter", function(c) - c:emit_signal("request::activate", "mouse_enter", { raise = false }) + c:emit_signal("request::activate", "mouse_enter", { raise = false }) end) -- Workaround for focused border color, why in the love of god doesnt it work with -- beautiful.border_focus client.connect_signal("focus", function(c) - c.border_color = "#616161" + c.border_color = "#616161" end) client.connect_signal("unfocus", function(c) - c.border_color = beautiful.border_normal + c.border_color = beautiful.border_normal end) function Hover_signal(widget, bg, fg) - local old_wibox, old_cursor, old_bg, old_fg - widget:connect_signal( - "mouse::enter", - function() - if bg then - old_bg = widget.bg - if string.len(bg) == 7 then - widget.bg = bg .. 'dd' - else - widget.bg = bg - end - end - if fg then - old_fg = widget.fg - widget.fg = fg - end - local w = mouse.current_wibox - if w then - old_cursor, old_wibox = w.cursor, w - w.cursor = "hand1" - end - end - ) + local old_wibox, old_cursor, old_bg, old_fg + widget:connect_signal( + "mouse::enter", + function() + if bg then + old_bg = widget.bg + if string.len(bg) == 7 then + widget.bg = bg .. 'dd' + else + widget.bg = bg + end + end + if fg then + old_fg = widget.fg + widget.fg = fg + end + local w = mouse.current_wibox + if w then + old_cursor, old_wibox = w.cursor, w + w.cursor = "hand1" + end + end + ) - widget:connect_signal( - "button::press", - function() - if bg then - if bg then - if string.len(bg) == 7 then - widget.bg = bg .. 'bb' - else - widget.bg = bg - end - end - end - if fg then - widget.fg = fg - end + widget:connect_signal( + "button::press", + function() + if bg then + if bg then + if string.len(bg) == 7 then + widget.bg = bg .. 'bb' + else + widget.bg = bg end - ) + end + end + if fg then + widget.fg = fg + end + end + ) - widget:connect_signal( - "button::release", - function() - if bg then - if bg then - if string.len(bg) == 7 then - widget.bg = bg .. 'dd' - else - widget.bg = bg - end - end - end - if fg then - widget.fg = fg - end + widget:connect_signal( + "button::release", + function() + if bg then + if bg then + if string.len(bg) == 7 then + widget.bg = bg .. 'dd' + else + widget.bg = bg end - ) + end + end + if fg then + widget.fg = fg + end + end + ) - widget:connect_signal( - "mouse::leave", - function() - if bg then - widget.bg = old_bg - end - if fg then - widget.fg = old_fg - end - if old_wibox then - old_wibox.cursor = old_cursor - old_wibox = nil - end - end - ) + widget:connect_signal( + "mouse::leave", + function() + if bg then + widget.bg = old_bg + end + if fg then + widget.fg = old_fg + end + if old_wibox then + old_wibox.cursor = old_cursor + old_wibox = nil + end + end + ) end diff --git a/awesome/src/modules/brightness_osd.lua b/awesome/src/modules/brightness_osd.lua index 252da62..728eef1 100644 --- a/awesome/src/modules/brightness_osd.lua +++ b/awesome/src/modules/brightness_osd.lua @@ -15,222 +15,220 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/brightness/" BACKLIGHT_MAX_BRIGHTNESS = 0 BACKLIGHT_SEPS = 0 awful.spawn.easy_async_with_shell( - "pkexec xfpm-power-backlight-helper --get-max-brightness", - function(stdout) - BACKLIGHT_MAX_BRIGHTNESS = tonumber(stdout) - BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100 - BACKLIGHT_SEPS = math.floor(BACKLIGHT_SEPS) - end + "pkexec xfpm-power-backlight-helper --get-max-brightness", + function(stdout) + BACKLIGHT_MAX_BRIGHTNESS = tonumber(stdout) + BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100 + BACKLIGHT_SEPS = math.floor(BACKLIGHT_SEPS) +end ) return function(s) - local brightness_osd_widget = wibox.widget { + local brightness_osd_widget = wibox.widget { + { + { { + { + nil, { - { - { - nil, - { - nil, - { - id = "icon", - forced_height = dpi(220), - image = icondir .. "brightness-high.svg", - widget = wibox.widget.imagebox - }, - nil, - expand = "none", - id = "icon_margin2", - layout = wibox.layout.align.vertical - }, - nil, - id = "icon_margin1", - expand = "none", - layout = wibox.layout.align.horizontal - }, - { - { - id = "label", - text = "Brightness", - align = "left", - valign = "center", - widget = wibox.widget.textbox - }, - nil, - { - id = "value", - text = "0%", - align = "center", - valign = "center", - widget = wibox.widget.textbox - }, - id = "label_value_layout", - forced_height = dpi(48), - layout = wibox.layout.align.horizontal, - }, - { - { - id = "brightness_slider", - bar_shape = gears.shape.rounded_rect, - bar_height = dpi(10), - bar_color = color["Grey800"] .. "88", - bar_active_color = "#ffffff", - handle_color = "#ffffff", - handle_shape = gears.shape.circle, - handle_width = dpi(10), - handle_border_color = color["White"], - maximum = 100, - widget = wibox.widget.slider - }, - id = "slider_layout", - forced_height = dpi(24), - widget = wibox.container.place - }, - id = "icon_slider_layout", - spacing = dpi(0), - layout = wibox.layout.align.vertical - }, - id = "osd_layout", - layout = wibox.layout.align.vertical + nil, + { + id = "icon", + forced_height = dpi(220), + image = icondir .. "brightness-high.svg", + widget = wibox.widget.imagebox + }, + nil, + expand = "none", + id = "icon_margin2", + layout = wibox.layout.align.vertical }, - id = "container", - left = dpi(24), - right = dpi(24), - widget = wibox.container.margin + nil, + id = "icon_margin1", + expand = "none", + layout = wibox.layout.align.horizontal + }, + { + { + id = "label", + text = "Brightness", + align = "left", + valign = "center", + widget = wibox.widget.textbox + }, + nil, + { + id = "value", + text = "0%", + align = "center", + valign = "center", + widget = wibox.widget.textbox + }, + id = "label_value_layout", + forced_height = dpi(48), + layout = wibox.layout.align.horizontal, + }, + { + { + id = "brightness_slider", + bar_shape = gears.shape.rounded_rect, + bar_height = dpi(10), + bar_color = color["Grey800"] .. "88", + bar_active_color = "#ffffff", + handle_color = "#ffffff", + handle_shape = gears.shape.circle, + handle_width = dpi(10), + handle_border_color = color["White"], + maximum = 100, + widget = wibox.widget.slider + }, + id = "slider_layout", + forced_height = dpi(24), + widget = wibox.container.place + }, + id = "icon_slider_layout", + spacing = dpi(0), + layout = wibox.layout.align.vertical }, - bg = color["Grey900"] .. "88", - widget = wibox.container.background, - ontop = true, - visible = true, - type = "notification", - forced_height = dpi(300), - forced_width = dpi(300), - offset = dpi(5), - } + id = "osd_layout", + layout = wibox.layout.align.vertical + }, + id = "container", + left = dpi(24), + right = dpi(24), + widget = wibox.container.margin + }, + bg = color["Grey900"] .. "88", + widget = wibox.container.background, + ontop = true, + visible = true, + type = "notification", + forced_height = dpi(300), + forced_width = dpi(300), + offset = dpi(5), + } - brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal( - "property::value", - function() - awful.spawn.easy_async_with_shell( - "pkexec xfpm-power-backlight-helper --get-brightness", - function(stdout) - local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100) - -- Performance is horrible, or it overrides and executes at the same time as the keymappings - --awful.spawn("xbacklight -set " .. brightness_value, false) - brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(tostring(brightness_value) .. "%") + brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal( + "property::value", + function() + awful.spawn.easy_async_with_shell( + "pkexec xfpm-power-backlight-helper --get-brightness", + function(stdout) + local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100) + brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(tostring(brightness_value) .. "%") - awesome.emit_signal( - "widget::brightness:update", - brightness_value - ) - - if awful.screen.focused().show_brightness_osd then - awesome.emit_signal( - "module::brightness_osd:show", - true - ) - end - - local icon = icondir .. "brightness" - if brightness_value >= 0 and brightness_value < 34 then - icon = icon .. "-low" - elseif brightness_value >= 34 and brightness_value < 67 then - icon = icon .. "-medium" - elseif brightness_value >= 67 then - icon = icon .. "-high" - end - brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg") - end - ) - end - ) - - local update_slider = function() - awful.spawn.easy_async_with_shell( - [[ pkexec xfpm-power-backlight-helper --get-brightness ]], - function(stdout) - stdout = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100) - brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(stdout) - end - ) - end - - awesome.connect_signal( - "module::brightness_slider:update", - function() - update_slider() - end - ) - - awesome.connect_signal( + awesome.emit_signal( "widget::brightness:update", - function(value) - brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(value)) - end - ) + brightness_value + ) + if awful.screen.focused().show_brightness_osd then + awesome.emit_signal( + "module::brightness_osd:show", + true + ) + end + + local icon = icondir .. "brightness" + if brightness_value >= 0 and brightness_value < 34 then + icon = icon .. "-low" + elseif brightness_value >= 34 and brightness_value < 67 then + icon = icon .. "-medium" + elseif brightness_value >= 67 then + icon = icon .. "-high" + end + brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg") + end + ) + end + ) + + local update_slider = function() + awful.spawn.easy_async_with_shell( + [[ pkexec xfpm-power-backlight-helper --get-brightness ]], + function(stdout) + stdout = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100) + brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(stdout) + end + ) + end + + awesome.connect_signal( + "module::brightness_slider:update", + function() update_slider() + end + ) - local brightness_container = awful.popup { - widget = wibox.container.background, - ontop = true, - bg = color["Grey900"] .. "00", - stretch = false, - visible = false, - screen = s, - placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 15) - end - } + awesome.connect_signal( + "widget::brightness:update", + function(value) + brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(value)) + end + ) - local hide_brightness_osd = gears.timer { - timeout = 2, - autostart = true, - callback = function() - brightness_container.visible = false - end - } + update_slider() - brightness_container:setup { - brightness_osd_widget, - layout = wibox.layout.fixed.horizontal - } + local brightness_container = awful.popup { + widget = wibox.container.background, + ontop = true, + bg = color["Grey900"] .. "00", + stretch = false, + visible = false, + screen = s, + placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 15) + end + } - awesome.connect_signal( - "widget::brightness_osd:rerun", - function() - if hide_brightness_osd.started then - hide_brightness_osd:again() - else - hide_brightness_osd:start() - end - end - ) + local hide_brightness_osd = gears.timer { + timeout = 2, + autostart = true, + callback = function() + brightness_container.visible = false + end + } - awesome.connect_signal( - "module::brightness_osd:show", - function() - if s == mouse.screen then - brightness_container.visible = true - end - end - ) + brightness_container:setup { + brightness_osd_widget, + layout = wibox.layout.fixed.horizontal + } - brightness_container:connect_signal( - "mouse::enter", - function() - brightness_container.visible = true - hide_brightness_osd:stop() - end - ) + awesome.connect_signal( + "widget::brightness_osd:rerun", + function() + if hide_brightness_osd.started then + hide_brightness_osd:again() + else + hide_brightness_osd:start() + end + end + ) - brightness_container:connect_signal( - "mouse::leave", - function() - brightness_container.visible = true - hide_brightness_osd:again() - end - ) + awesome.connect_signal( + "module::brightness_osd:show", + function() + if s == mouse.screen then + brightness_container.visible = true + end + end + ) + + brightness_container:connect_signal( + "mouse::enter", + function() + brightness_container.visible = true + hide_brightness_osd:stop() + end + ) + + brightness_container:connect_signal( + "mouse::leave", + function() + brightness_container.visible = true + hide_brightness_osd:again() + end + ) end diff --git a/awesome/src/modules/calendar_osd.lua b/awesome/src/modules/calendar_osd.lua deleted file mode 100644 index 30dae45..0000000 --- a/awesome/src/modules/calendar_osd.lua +++ /dev/null @@ -1,183 +0,0 @@ ---------------------------------------- --- This is the calendar_osd module -- ---------------------------------------- - --- Awesome Libs - -local awful = require("awful") -local wibox = require("wibox") -local gears = require("gears") -local dpi = require("beautiful").xresources.apply_dpi -local color = require("src.theme.colors") - -return function(s) - local styles = {} - - styles.month = { - padding = 15, - bg_color = color["Grey900"], - border_width = 1, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end - } - styles.normal = { - fg_color = color["Grey900"], - font = user_vars.font.extrabold, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end - } - styles.focus = { - fg_color = color["Grey900"], - bg_color = color["Purple200"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end - } - styles.header = { - fg_color = color["Grey900"], - bg_color = color["Teal200"], - markup = function(t) return '' .. t .. '' end, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end - } - styles.weekday = { - padding = 8, - fg_color = color["Grey900"], - bg_color = color["Teal200"], - markup = function(t) return '' .. t .. '' end, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end - } - local function decorate_cell(widget, flag, date) - if flag == 'monthheader' and not styles.monthheader then - flag = 'header' - end - local props = styles[flag] or {} - if props.markup and widget.get_text and widget.set_markup then - widget:set_markup(props.markup(widget:get_text())) - end - -- Change bg color for weekends - local d = { year = date.year, month = (date.month or 1), day = (date.day or 1) } - local weekday = tonumber(os.date('%w', os.time(d))) - local default_bg = (weekday == 0 or weekday == 6) and color["Red200"] or color["White"] - local ret = wibox.widget { - { - widget, - left = dpi(8), - right = dpi(8), - top = dpi(4), - bottom = dpi(4), - widget = wibox.container.margin - }, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - fg = props.fg_color or '#999999', - bg = props.bg_color or default_bg, - widget = wibox.container.background - } - return ret - end - - local calendar = wibox.widget { - date = os.date('*t'), - fn_embed = decorate_cell, - widget = wibox.widget.calendar.month, - font = user_vars.font.extrabold, - spacing = dpi(10) - } - - local calendar_osd_widget = wibox.widget { - { - widget = wibox.widget.textbox, - fg = "#ffffff", - align = "center", - valign = "center", - font = "DS-Digital, Bold Italic 50", - id = "digital_clock" - }, - { - widget = calendar - }, - visible = true, - layout = wibox.layout.fixed.vertical - } - - local set_clock = function() - calendar_osd_widget.digital_clock:set_text(os.date("%H:%M")) - end - - local calendar_clock_update = gears.timer { - timeout = 5, - autostart = true, - call_now = true, - callback = function() - set_clock() - end - } - - local calendar_osd_container = awful.popup { - screen = s, - widget = wibox.container.background, - ontop = true, - bg = color["Grey900"], - stretch = false, - visible = false, - placement = function(c) awful.placement.top_right(c, { margins = { right = dpi(100), top = dpi(60) } }) end, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end - } - - local hide_osd = gears.timer { - timeout = 0.25, - autostart = true, - callback = function() - calendar_osd_container.visible = false - end - } - - calendar_osd_container:setup { - calendar_osd_widget, - layout = wibox.layout.align.horizontal - } - - calendar_osd_container:connect_signal( - "mouse::enter", - function() - calendar_osd_container.visible = true - hide_osd:stop() - end - ) - - calendar_osd_container:connect_signal( - "mouse::leave", - function() - calendar_osd_container.visible = false - hide_osd:stop() - end - ) - - awesome.connect_signal( - "widget::calendar_osd:stop", - function() - calendar_osd_container.visible = true - hide_osd:stop() - end - ) - - awesome.connect_signal( - "widget::calendar_osd:rerun", - function() - if hide_osd.started then - hide_osd:again() - else - hide_osd:start() - end - end - ) -end diff --git a/awesome/src/modules/powermenu.lua b/awesome/src/modules/powermenu.lua index 19f686f..4023df2 100644 --- a/awesome/src/modules/powermenu.lua +++ b/awesome/src/modules/powermenu.lua @@ -15,32 +15,32 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/powermenu/" return function(s) - -- Profile picture imagebox - local profile_picture = wibox.widget { - image = icondir .. "defaultpfp.svg", - resize = true, - forced_height = dpi(200), - clip_shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 30) - end, - widget = wibox.widget.imagebox - } + -- Profile picture imagebox + local profile_picture = wibox.widget { + image = icondir .. "defaultpfp.svg", + resize = true, + forced_height = dpi(200), + clip_shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 30) + end, + widget = wibox.widget.imagebox + } - -- Username textbox - local profile_name = wibox.widget { - align = 'center', - valign = 'center', - text = " ", - font = "JetBrains Mono Bold 30", - widget = wibox.widget.textbox - } + -- Username textbox + local profile_name = wibox.widget { + align = 'center', + valign = 'center', + text = " ", + font = "JetBrains Mono Bold 30", + widget = wibox.widget.textbox + } - -- Get the profile script from /var/lib/AccountsService/icons/${USER} - -- and copy it to the assets folder - -- TODO: If the user doesnt have AccountsService look into $HOME/.faces - local update_profile_picture = function() - awful.spawn.easy_async_with_shell( - [=[ + -- Get the profile script from /var/lib/AccountsService/icons/${USER} + -- and copy it to the assets folder + -- TODO: If the user doesnt have AccountsService look into $HOME/.faces + local update_profile_picture = function() + awful.spawn.easy_async_with_shell( + [=[ iconPath="/var/lib/AccountsService/icons/${USER}" userIconPath="${HOME}/.config/awesome/src/assets/userpfp/" if [[ -f "${userIconPath}" ]]; @@ -65,23 +65,23 @@ return function(s) fi fi ]=], - function(stdout) - if stdout then - profile_picture:set_image(stdout:gsub("\n", "")) - else - profile_picture:set_image(icondir .. "defaultpfp.svg") - end - end - ) + function(stdout) + if stdout then + profile_picture:set_image(stdout:gsub("\n", "")) + else + profile_picture:set_image(icondir .. "defaultpfp.svg") + end end - update_profile_picture() + ) + end + update_profile_picture() - -- Will determin the display style - local namestyle = user_vars.namestyle - -- Get the full username(if set) and the username + hostname - local update_user_name = function() - awful.spawn.easy_async_with_shell( - [=[ + -- Will determin the display style + local namestyle = user_vars.namestyle + -- Get the full username(if set) and the username + hostname + local update_user_name = function() + awful.spawn.easy_async_with_shell( + [=[ fullname="$(getent passwd `whoami` | cut -d ':' -f 5)" user="$(whoami)" host="$(hostname)" @@ -95,227 +95,227 @@ return function(s) printf "Rick Astley" fi ]=], - function(stdout) - if stdout:gsub("\n", "") == "Rick Astley" then - profile_picture:set_image(awful.util.getdir("config") .. "src/assets/userpfp/" .. "rickastley.jpg") - end - profile_name:set_text(stdout) - end - ) + function(stdout) + if stdout:gsub("\n", "") == "Rick Astley" then + profile_picture:set_image(awful.util.getdir("config") .. "src/assets/userpfp/" .. "rickastley.jpg") + end + profile_name:set_text(stdout) end - update_user_name() + ) + end + update_user_name() - -- Universal Button widget - local button = function(name, icon, bg_color, callback) - local item = wibox.widget { + -- Universal Button widget + local button = function(name, icon, bg_color, callback) + local item = wibox.widget { + { + { + { { - { - { - { - { - -- TODO: using gears.color to recolor a SVG will make it look super low res - -- currently I recolor it in the .svg file directly, but later implement - -- a better way to recolor a SVG - -- image = gears.color.recolor_image(icon, color["Grey900"]), - image = icon, - resize = true, - forced_height = dpi(30), - widget = wibox.widget.imagebox - }, - margins = dpi(0), - widget = wibox.container.margin - }, - { - { - text = name, - font = "JetBrains Mono Bold 30", - widget = wibox.widget.textbox - }, - margins = dpi(0), - widget = wibox.container.margin - }, - widget = wibox.layout.fixed.horizontal - }, - margins = dpi(10), - widget = wibox.container.margin - }, - fg = color["Grey900"], - bg = bg_color, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 10) - end, - widget = wibox.container.background, - id = 'background' + { + -- TODO: using gears.color to recolor a SVG will make it look super low res + -- currently I recolor it in the .svg file directly, but later implement + -- a better way to recolor a SVG + -- image = gears.color.recolor_image(icon, color["Grey900"]), + image = icon, + resize = true, + forced_height = dpi(30), + widget = wibox.widget.imagebox + }, + margins = dpi(0), + widget = wibox.container.margin }, - spacing = dpi(0), - layout = wibox.layout.align.vertical - } + { + { + text = name, + font = "JetBrains Mono Bold 30", + widget = wibox.widget.textbox + }, + margins = dpi(0), + widget = wibox.container.margin + }, + widget = wibox.layout.fixed.horizontal + }, + margins = dpi(10), + widget = wibox.container.margin + }, + fg = color["Grey900"], + bg = bg_color, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 10) + end, + widget = wibox.container.background, + id = 'background' + }, + spacing = dpi(0), + layout = wibox.layout.align.vertical + } - item:connect_signal( - "button::release", - function() - callback() - end - ) - - return item + item:connect_signal( + "button::release", + function() + callback() end + ) - -- Create the power menu actions - local suspend_command = function() - awful.spawn("dm-tool lock & systemctl suspend") - awesome.emit_signal("module::powermenu:hide") - end + return item + end - local logout_command = function() - awesome.quit() - end + -- Create the power menu actions + local suspend_command = function() + awful.spawn("dm-tool lock & systemctl suspend") + awesome.emit_signal("module::powermenu:hide") + end - local lock_command = function() - awful.spawn("dm-tool lock") - awesome.emit_signal("module::powermenu:hide") - end + local logout_command = function() + awesome.quit() + end - local shutdown_command = function() - awful.spawn("shutdown now") - awesome.emit_signal("module::powermenu:hide") - end + local lock_command = function() + awful.spawn("dm-tool lock") + awesome.emit_signal("module::powermenu:hide") + end - local reboot_command = function() - awful.spawn("reboot") - awesome.emit_signal("module::powermenu:hide") - end + local shutdown_command = function() + awful.spawn("shutdown now") + awesome.emit_signal("module::powermenu:hide") + end - -- Create the buttons with their command and name etc - local shutdown_button = button("Shutdown", icondir .. "shutdown.svg", color["Blue200"], shutdown_command) - local reboot_button = button("Reboot", icondir .. "reboot.svg", color["Red200"], reboot_command) - local suspend_button = button("Suspend", icondir .. "suspend.svg", color["Yellow200"], suspend_command) - local logout_button = button("Logout", icondir .. "logout.svg", color["Green200"], logout_command) - local lock_button = button("Lock", icondir .. "lock.svg", color["Orange200"], lock_command) + local reboot_command = function() + awful.spawn("reboot") + awesome.emit_signal("module::powermenu:hide") + end - -- Signals to change color on hover - Hover_signal(shutdown_button.background, color["Blue200"]) - Hover_signal(reboot_button.background, color["Red200"]) - Hover_signal(suspend_button.background, color["Yellow200"]) - Hover_signal(logout_button.background, color["Green200"]) - Hover_signal(lock_button.background, color["Orange200"]) + -- Create the buttons with their command and name etc + local shutdown_button = button("Shutdown", icondir .. "shutdown.svg", color["Blue200"], shutdown_command) + local reboot_button = button("Reboot", icondir .. "reboot.svg", color["Red200"], reboot_command) + local suspend_button = button("Suspend", icondir .. "suspend.svg", color["Yellow200"], suspend_command) + local logout_button = button("Logout", icondir .. "logout.svg", color["Green200"], logout_command) + local lock_button = button("Lock", icondir .. "lock.svg", color["Orange200"], lock_command) - -- The powermenu widget - local powermenu = wibox.widget { - layout = wibox.layout.align.vertical, - expand = "none", + -- Signals to change color on hover + Hover_signal(shutdown_button.background, color["Blue200"]) + Hover_signal(reboot_button.background, color["Red200"]) + Hover_signal(suspend_button.background, color["Yellow200"]) + Hover_signal(logout_button.background, color["Green200"]) + Hover_signal(lock_button.background, color["Orange200"]) + + -- The powermenu widget + local powermenu = wibox.widget { + layout = wibox.layout.align.vertical, + expand = "none", + nil, + { + { nil, { + { + nil, { - nil, - { - { - nil, - { - nil, - { - profile_picture, - margins = dpi(0), - widget = wibox.container.margin - }, - nil, - expand = "none", - layout = wibox.layout.align.horizontal - }, - nil, - layout = wibox.layout.align.vertical, - expand = "none" - }, - spacing = dpi(50), - { - profile_name, - margins = dpi(0), - widget = wibox.container.margin - }, - layout = wibox.layout.fixed.vertical - }, - nil, - expand = "none", - layout = wibox.layout.align.horizontal + nil, + { + profile_picture, + margins = dpi(0), + widget = wibox.container.margin + }, + nil, + expand = "none", + layout = wibox.layout.align.horizontal }, - { - nil, - { - { - shutdown_button, - reboot_button, - logout_button, - lock_button, - suspend_button, - spacing = dpi(30), - layout = wibox.layout.fixed.horizontal - }, - margins = dpi(0), - widget = wibox.container.margin - }, - nil, - expand = "none", - layout = wibox.layout.align.horizontal - }, - layout = wibox.layout.align.vertical + nil, + layout = wibox.layout.align.vertical, + expand = "none" + }, + spacing = dpi(50), + { + profile_name, + margins = dpi(0), + widget = wibox.container.margin + }, + layout = wibox.layout.fixed.vertical }, - nil - } + nil, + expand = "none", + layout = wibox.layout.align.horizontal + }, + { + nil, + { + { + shutdown_button, + reboot_button, + logout_button, + lock_button, + suspend_button, + spacing = dpi(30), + layout = wibox.layout.fixed.horizontal + }, + margins = dpi(0), + widget = wibox.container.margin + }, + nil, + expand = "none", + layout = wibox.layout.align.horizontal + }, + layout = wibox.layout.align.vertical + }, + nil + } - -- Container for the widget, covers the entire screen - local powermenu_container = wibox { - widget = powermenu, - screen = s, - type = "splash", - visible = false, - ontop = true, - bg = "#21212188", - height = s.geometry.height, - width = s.geometry.width, - x = s.geometry.x, - y = s.geometry.y - } + -- Container for the widget, covers the entire screen + local powermenu_container = wibox { + widget = powermenu, + screen = s, + type = "splash", + visible = false, + ontop = true, + bg = "#21212188", + height = s.geometry.height, + width = s.geometry.width, + x = s.geometry.x, + y = s.geometry.y + } - -- Close on rightclick - powermenu_container:buttons( - gears.table.join( - awful.button( - {}, - 3, - function() - awesome.emit_signal("module::powermenu:hide") - end - ) - ) - ) - - -- Close on Escape - local powermenu_keygrabber = awful.keygrabber { - autostart = false, - stop_event = 'release', - keypressed_callback = function(self, mod, key, command) - if key == 'Escape' then - awesome.emit_signal("module::powermenu:hide") - end - end - } - - -- Signals - awesome.connect_signal( - "module::powermenu:show", + -- Close on rightclick + powermenu_container:buttons( + gears.table.join( + awful.button( + {}, + 3, function() - if s == mouse.screen then - powermenu_container.visible = true - powermenu_keygrabber:start() - end - end + awesome.emit_signal("module::powermenu:hide") + end + ) ) + ) - awesome.connect_signal( - "module::powermenu:hide", - function() - powermenu_keygrabber:stop() - powermenu_container.visible = false - end - ) + -- Close on Escape + local powermenu_keygrabber = awful.keygrabber { + autostart = false, + stop_event = 'release', + keypressed_callback = function(self, mod, key, command) + if key == 'Escape' then + awesome.emit_signal("module::powermenu:hide") + end + end + } + + -- Signals + awesome.connect_signal( + "module::powermenu:show", + function() + if s == mouse.screen then + powermenu_container.visible = true + powermenu_keygrabber:start() + end + end + ) + + awesome.connect_signal( + "module::powermenu:hide", + function() + powermenu_keygrabber:stop() + powermenu_container.visible = false + end + ) end diff --git a/awesome/src/modules/titlebar.lua b/awesome/src/modules/titlebar.lua index 6f306b9..ad4e401 100644 --- a/awesome/src/modules/titlebar.lua +++ b/awesome/src/modules/titlebar.lua @@ -17,235 +17,236 @@ awful.titlebar.enable_tooltip = true awful.titlebar.fallback_name = 'Client' local double_click_event_handler = function(double_click_event) - if double_click_timer then - double_click_timer:stop() - double_click_timer = nil - double_click_event() - return - end - double_click_timer = gears.timer.start_new( - 0.20, - function() - double_click_timer = nil - return false - end - ) + if double_click_timer then + double_click_timer:stop() + double_click_timer = nil + double_click_event() + return + end + double_click_timer = gears.timer.start_new( + 0.20, + function() + double_click_timer = nil + return false + end + ) end local create_click_events = function(c) - local buttons = gears.table.join( - awful.button( - {}, - 1, - function() - double_click_event_handler(function() - if c.floating then - c.float = false - return - end - c.maximized = not c.maximized - c:raise() - end) - c:activate { context = 'titlebar', action = 'mouse_move' } - end - ), - awful.button( - {}, - 3, - function() - c:activate { context = 'titlebar', action = 'mouse_resize' } - end - ) + local buttons = gears.table.join( + awful.button( + {}, + 1, + function() + double_click_event_handler(function() + if c.floating then + c.float = false + return + end + c.maximized = not c.maximized + c:raise() + end) + c:activate { context = 'titlebar', action = 'mouse_move' } + end + ), + awful.button( + {}, + 3, + function() + c:activate { context = 'titlebar', action = 'mouse_resize' } + end ) - return buttons + ) + return buttons end local create_titlebar = function(c, bg, size) - local titlebar = awful.titlebar(c, { - position = "left", - bg = bg, - size = size - }) + local titlebar = awful.titlebar(c, { + position = "left", + bg = bg, + size = size + }) - titlebar:setup { + titlebar:setup { + { + { { - { - { - awful.titlebar.widget.closebutton(c), - widget = wibox.container.background, - bg = color["Red200"], - shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) - end, - id = "closebutton" - }, - { - awful.titlebar.widget.maximizedbutton(c), - widget = wibox.container.background, - bg = color["Yellow200"], - shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) - end, - id = "maximizebutton" - }, - { - awful.titlebar.widget.minimizebutton(c), - widget = wibox.container.background, - bg = color["Green200"], - shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) - end, - id = "minimizebutton" - }, - spacing = dpi(10), - layout = wibox.layout.fixed.vertical, - id = "spacing" - }, - margins = dpi(8), - widget = wibox.container.margin, - id = "margin" + awful.titlebar.widget.closebutton(c), + widget = wibox.container.background, + bg = color["Red200"], + shape = function(cr, height, width) + gears.shape.rounded_rect(cr, width, height, 4) + end, + id = "closebutton" }, { - buttons = create_click_events(c), - layout = wibox.layout.flex.vertical + awful.titlebar.widget.maximizedbutton(c), + widget = wibox.container.background, + bg = color["Yellow200"], + shape = function(cr, height, width) + gears.shape.rounded_rect(cr, width, height, 4) + end, + id = "maximizebutton" }, { - { - widget = awful.widget.clienticon(c) - }, - margins = dpi(5), - widget = wibox.container.margin + awful.titlebar.widget.minimizebutton(c), + widget = wibox.container.background, + bg = color["Green200"], + shape = function(cr, height, width) + gears.shape.rounded_rect(cr, width, height, 4) + end, + id = "minimizebutton" }, - layout = wibox.layout.align.vertical, - id = "main" - } - Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"]) - Hover_signal(titlebar.main.margin.spacing.maximizebutton, color["Yellow200"]) - Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"]) + spacing = dpi(10), + layout = wibox.layout.fixed.vertical, + id = "spacing" + }, + margins = dpi(8), + widget = wibox.container.margin, + id = "margin" + }, + { + buttons = create_click_events(c), + layout = wibox.layout.flex.vertical + }, + { + { + widget = awful.widget.clienticon(c) + }, + margins = dpi(5), + widget = wibox.container.margin + }, + layout = wibox.layout.align.vertical, + id = "main" + } + Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"]) + Hover_signal(titlebar.main.margin.spacing.maximizebutton, color["Yellow200"]) + Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"]) end local create_titlebar_dialog = function(c, bg, size) - local titlebar = awful.titlebar(c, { - position = "left", - bg = bg, - size = size - }) + local titlebar = awful.titlebar(c, { + position = "left", + bg = bg, + size = size + }) - titlebar:setup { + titlebar:setup { + { + { { - { - { - awful.titlebar.widget.closebutton(c), - widget = wibox.container.background, - bg = color["Red200"], - shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) - end, - id = "closebutton" - }, - { - awful.titlebar.widget.minimizebutton(c), - widget = wibox.container.background, - bg = color["Green200"], - shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) - end, - id = "minimizebutton" - }, - spacing = dpi(10), - layout = wibox.layout.fixed.vertical, - id = "spacing" - }, - margins = dpi(8), - widget = wibox.container.margin, - id = "margin" + awful.titlebar.widget.closebutton(c), + widget = wibox.container.background, + bg = color["Red200"], + shape = function(cr, height, width) + gears.shape.rounded_rect(cr, width, height, 4) + end, + id = "closebutton" }, { - buttons = create_click_events(c), - layout = wibox.layout.flex.vertical + awful.titlebar.widget.minimizebutton(c), + widget = wibox.container.background, + bg = color["Green200"], + shape = function(cr, height, width) + gears.shape.rounded_rect(cr, width, height, 4) + end, + id = "minimizebutton" }, - { - { - widget = awful.widget.clienticon(c) - }, - margins = dpi(5), - widget = wibox.container.margin - }, - layout = wibox.layout.align.vertical, - id = "main" - } - Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"]) - Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"]) + spacing = dpi(10), + layout = wibox.layout.fixed.vertical, + id = "spacing" + }, + margins = dpi(8), + widget = wibox.container.margin, + id = "margin" + }, + { + buttons = create_click_events(c), + layout = wibox.layout.flex.vertical + }, + { + { + widget = awful.widget.clienticon(c) + }, + margins = dpi(5), + widget = wibox.container.margin + }, + layout = wibox.layout.align.vertical, + id = "main" + } + Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"]) + Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"]) end local draw_titlebar = function(c) - if c.type == 'normal' and not c.requests_no_titlebar then - if c.class == 'Firefox' then - create_titlebar(c, '#121212AA', 35) - elseif c.name == "Steam" then - create_titlebar(c, '#121212AA', 0) - elseif c.name == "Settings" then - create_titlebar(c, '#121212AA', 0) - elseif c.class == "gcr-prompter" or c.class == "Gcr-prompter" then - create_titlebar(c, '#121212AA', 0) - else - create_titlebar(c, '#121212AA', 35) - end - elseif c.type == 'dialog' then - create_titlebar_dialog(c, '#121212AA', 35) + if c.type == 'normal' and not c.requests_no_titlebar then + if c.class == 'Firefox' then + create_titlebar(c, '#121212AA', 35) + elseif c.name == "Steam" then + create_titlebar(c, '#121212AA', 0) + elseif c.name == "Settings" then + create_titlebar(c, '#121212AA', 0) + elseif c.class == "gcr-prompter" or c.class == "Gcr-prompter" then + create_titlebar(c, '#121212AA', 0) + else + create_titlebar(c, '#121212AA', 35) end + elseif c.type == 'dialog' then + create_titlebar_dialog(c, '#121212AA', 35) + end end client.connect_signal( - "property::maximized", - function(c) - if c.maximized then - Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg" - elseif not c.minimized then - Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg" - end - end + "property::maximized", + function(c) + if c.maximized then + Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg" + Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg" + Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg" + elseif not c.minimized then + Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" + Theme.titlebar_maximized_button_active = icondir .. "maximize.svg" + Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg" + end +end ) client.connect_signal( - "request::titlebars", - function(c) - if c.maximized then - Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg" - elseif not c.minimized then - Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg" - end - draw_titlebar(c) - if not c.floating or c.maximized then - awful.titlebar.hide(c, 'left') - awful.titlebar.hide(c, 'right') - awful.titlebar.hide(c, 'top') - awful.titlebar.hide(c, 'bottom') - end - end + "request::titlebars", + function(c) + if c.maximized then + Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg" + Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg" + Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg" + draw_titlebar(c) + elseif not c.minimized then + Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" + Theme.titlebar_maximized_button_active = icondir .. "maximize.svg" + Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg" + draw_titlebar(c) + end + if not c.floating or c.maximized then + awful.titlebar.hide(c, 'left') + awful.titlebar.hide(c, 'right') + awful.titlebar.hide(c, 'top') + awful.titlebar.hide(c, 'bottom') + end +end ) client.connect_signal( - 'property::floating', - function(c) - if c.floating or (c.floating and c.maximized) then - awful.titlebar.show(c, 'left') - awful.titlebar.hide(c, 'right') - awful.titlebar.hide(c, 'top') - awful.titlebar.hide(c, 'bottom') - else - awful.titlebar.hide(c, 'left') - awful.titlebar.hide(c, 'right') - awful.titlebar.hide(c, 'top') - awful.titlebar.hide(c, 'bottom') - end - end + 'property::floating', + function(c) + if c.floating or (c.floating and c.maximized) then + awful.titlebar.show(c, 'left') + awful.titlebar.hide(c, 'right') + awful.titlebar.hide(c, 'top') + awful.titlebar.hide(c, 'bottom') + else + awful.titlebar.hide(c, 'left') + awful.titlebar.hide(c, 'right') + awful.titlebar.hide(c, 'top') + awful.titlebar.hide(c, 'bottom') + end +end ) diff --git a/awesome/src/modules/volume_controller.lua b/awesome/src/modules/volume_controller.lua new file mode 100644 index 0000000..dbce44e --- /dev/null +++ b/awesome/src/modules/volume_controller.lua @@ -0,0 +1,792 @@ +----------------------------------- +-- This is the volume controller -- +----------------------------------- + +-- Awesome Libs +local awful = require("awful") +local color = require("src.theme.colors") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local wibox = require("wibox") +require("src.core.signals") + +-- Icon directory path +local icondir = awful.util.getdir("config") .. "src/assets/icons/audio/" + +-- Returns the volume controller +return function(s) + + local function create_device(name, node, sink) + local device = wibox.widget { + { + { + { + { + image = "", + id = "icon", + resize = false, + widget = wibox.widget.imagebox + }, + { + text = name, + id = "node", + widget = wibox.widget.textbox + }, + id = "device_layout", + layout = wibox.layout.align.horizontal + }, + id = "device_margin", + margins = dpi(5), + widget = wibox.container.margin + }, + id = "background", + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 4) + end, + widget = wibox.container.background + }, + margins = dpi(5), + widget = wibox.container.margin + } + + if sink == true then + device:connect_signal( + "button::press", + function() + awful.spawn.spawn("./.config/awesome/src/scripts/vol.sh set_sink " .. node) + + awesome.emit_signal("update::background:vol", node) + end + ) + + --#region Signal Functions + local old_wibox, old_cursor, old_bg, old_fg + local bg = "" + local fg = "" + local mouse_enter = function() + if bg then + old_bg = device.background.bg + device.background.bg = bg .. 'dd' + end + if fg then + old_fg = device.background.fg + device.background.fg = fg + end + local w = mouse.current_wibox + if w then + old_cursor, old_wibox = w.cursor, w + w.cursor = "hand1" + end + end + + local button_press = function() + if bg then + if bg then + if string.len(bg) == 7 then + device.background.bg = bg .. 'bb' + else + device.background.bg = bg + end + end + end + if fg then + device.background.fg = fg + end + end + + local button_release = function() + if bg then + if bg then + if string.len(bg) == 7 then + device.background.bg = bg .. 'dd' + else + device.background.bg = bg + end + end + end + if fg then + device.background.fg = fg + end + end + + local mouse_leave = function() + if bg then + device.background.bg = old_bg + end + if fg then + device.background.fg = old_fg + end + if old_wibox then + old_wibox.cursor = old_cursor + old_wibox = nil + end + end + + device:connect_signal( + "mouse::enter", + mouse_enter + ) + + device:connect_signal( + "button::press", + button_press + ) + + device:connect_signal( + "button::release", + button_release + ) + + device:connect_signal( + "mouse::leave", + mouse_leave + ) + --#endregion + + awesome.connect_signal( + "update::background:vol", + function(new_node) + if node == new_node then + old_bg = color["Purple200"] + old_fg = color["Grey900"] + bg = color["Purple200"] + fg = color["Grey900"] + device.background:set_bg(color["Purple200"]) + device.background:set_fg(color["Grey900"]) + else + fg = color["Purple200"] + bg = color["Grey700"] + device.background:set_fg(color["Purple200"]) + device.background:set_bg(color["Grey700"]) + end + end + ) + awful.spawn.easy_async_with_shell( + [[ pactl get-default-sink ]], + function(stdout) + local node_active = stdout:gsub("\n", "") + if node == node_active then + bg = color["Purple200"] + fg = color["Grey900"] + device.background:set_bg(color["Purple200"]) + device.background:set_fg(color["Grey900"]) + else + fg = color["Purple200"] + bg = color["Grey700"] + device.background:set_fg(color["Purple200"]) + device.background:set_bg(color["Grey700"]) + end + end + ) + else + + device:connect_signal( + "button::press", + function() + awful.spawn.spawn("./.config/awesome/src/scripts/mic.sh set_source " .. node) + + awesome.emit_signal("update::background:mic", node) + end + ) + + --#region Signal Functions + local old_wibox, old_cursor, old_bg, old_fg + local bg = "" + local fg = "" + local mouse_enter = function() + if bg then + old_bg = device.background.bg + device.background.bg = bg .. 'dd' + end + if fg then + old_fg = device.background.fg + device.background.fg = fg + end + local w = mouse.current_wibox + if w then + old_cursor, old_wibox = w.cursor, w + w.cursor = "hand1" + end + end + + local button_press = function() + if bg then + if bg then + if string.len(bg) == 7 then + device.background.bg = bg .. 'bb' + else + device.background.bg = bg + end + end + end + if fg then + device.background.fg = fg + end + end + + local button_release = function() + if bg then + if bg then + if string.len(bg) == 7 then + device.background.bg = bg .. 'dd' + else + device.background.bg = bg + end + end + end + if fg then + device.background.fg = fg + end + end + + local mouse_leave = function() + if bg then + device.background.bg = old_bg + end + if fg then + device.background.fg = old_fg + end + if old_wibox then + old_wibox.cursor = old_cursor + old_wibox = nil + end + end + + device:connect_signal( + "mouse::enter", + mouse_enter + ) + + device:connect_signal( + "button::press", + button_press + ) + + device:connect_signal( + "button::release", + button_release + ) + + device:connect_signal( + "mouse::leave", + mouse_leave + ) + --#endregion + + awesome.connect_signal( + "update::background:mic", + function(new_node) + if node == new_node then + old_bg = color["Blue200"] + old_fg = color["Grey900"] + bg = color["Blue200"] + fg = color["Grey900"] + device.background:set_bg(color["Blue200"]) + device.background:set_fg(color["Grey900"]) + else + fg = color["Blue200"] + bg = color["Grey700"] + device.background:set_fg(color["Blue200"]) + device.background:set_bg(color["Grey700"]) + end + end + ) + awful.spawn.easy_async_with_shell( + [[ pactl get-default-source ]], + function(stdout) + local node_active = stdout:gsub("\n", "") + if node == node_active then + bg = color["Blue200"] + fg = color["Grey900"] + device.background:set_bg(color["Blue200"]) + device.background:set_fg(color["Grey900"]) + else + fg = color["Blue200"] + bg = color["Grey700"] + device.background:set_fg(color["Blue200"]) + device.background:set_bg(color["Grey700"]) + end + end + ) + end + return device + end + + local dropdown_list_volume = wibox.widget { + { + { + layout = wibox.layout.fixed.vertical, + id = "volume_device_list" + }, + id = "volume_device_background", + bg = color["Grey800"], + shape = function(cr, width, height) + gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4) + end, + widget = wibox.container.background + }, + left = dpi(10), + right = dpi(10), + widget = wibox.container.margin + } + + local dropdown_list_microphone = wibox.widget { + { + { + layout = wibox.layout.fixed.vertical, + id = "volume_device_list" + }, + id = "volume_device_background", + bg = color["Grey800"], + shape = function(cr, width, height) + gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4) + end, + widget = wibox.container.background + }, + left = dpi(10), + right = dpi(10), + widget = wibox.container.margin + } + + local volume_controller = wibox.widget { + { + { + -- Audio Device selector + { + { + { + { + { + resize = false, + image = gears.color.recolor_image(icondir .. "menu-down.svg", color["Purple200"]), + widget = wibox.widget.imagebox, + id = "icon" + }, + id = "center", + halign = "center", + valign = "center", + widget = wibox.container.place, + }, + { + { + text = "Output Device", + widget = wibox.widget.textbox, + id = "device_name" + }, + margins = dpi(5), + widget = wibox.container.margin + }, + id = "audio_volume", + layout = wibox.layout.fixed.horizontal + }, + id = "audio_bg", + bg = color["Grey800"], + fg = color["Purple200"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 4) + end, + widget = wibox.container.background + }, + id = "audio_selector_margin", + left = dpi(10), + right = dpi(10), + top = dpi(10), + widget = wibox.container.margin + }, + { + id = "volume_list", + widget = dropdown_list_volume, + visible = false + }, + -- Microphone selector + { + { + { + { + { + resize = false, + image = gears.color.recolor_image(icondir .. "menu-down.svg", color["LightBlueA200"]), + widget = wibox.widget.imagebox, + id = "icon", + }, + id = "center", + halign = "center", + valign = "center", + widget = wibox.container.place, + }, + { + { + text = "Input Device", + widget = wibox.widget.textbox, + id = "device_name" + }, + margins = dpi(5), + widget = wibox.container.margin + }, + id = "mic_volume", + layout = wibox.layout.fixed.horizontal + }, + id = "mic_bg", + bg = color["Grey800"], + fg = color["LightBlueA200"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 4) + end, + widget = wibox.container.background + }, + id = "mic_selector_margin", + left = dpi(10), + right = dpi(10), + top = dpi(10), + widget = wibox.container.margin + }, + { + id = "mic_list", + widget = dropdown_list_microphone, + visible = false + }, + -- Audio volume slider + { + { + { + resize = false, + widget = wibox.widget.imagebox, + image = gears.color.recolor_image(icondir .. "volume-high.svg", color["Purple200"]), + id = "icon", + }, + { + { + bar_shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + bar_height = dpi(5), + bar_color = color["Grey800"], + bar_active_color = color["Purple200"], + handle_color = color["Purple200"], + handle_shape = gears.shape.circle, + handle_border_color = color["Purple200"], + handle_width = dpi(15), + maximum = 100, + forced_height = dpi(26), + widget = wibox.widget.slider, + id = "slider" + }, + bottom = dpi(12), + left = dpi(5), + id = "slider_margin", + widget = wibox.container.margin + }, + id = "audio_volume", + layout = wibox.layout.align.horizontal + }, + id = "audio_volume_margin", + top = dpi(10), + left = dpi(10), + right = dpi(10), + widget = wibox.container.margin + }, + -- Microphone volume slider + { + { + { + resize = false, + widget = wibox.widget.imagebox, + image = gears.color.recolor_image(icondir .. "microphone.svg", color["Blue200"]), + id = "icon" + }, + { + { + bar_shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + bar_height = dpi(5), + bar_color = color["Grey800"], + bar_active_color = color["Blue200"], + handle_color = color["Blue200"], + handle_shape = gears.shape.circle, + handle_border_color = color["Blue200"], + handle_width = dpi(15), + maximum = 100, + forced_height = dpi(26), + widget = wibox.widget.slider, + id = "slider" + }, + left = dpi(5), + id = "slider_margin", + widget = wibox.container.margin + }, + id = "mic_volume", + layout = wibox.layout.align.horizontal + }, + id = "mic_volume_margin", + left = dpi(10), + right = dpi(10), + widget = wibox.container.margin + }, + id = "controller_layout", + layout = wibox.layout.fixed.vertical + }, + id = "controller_margin", + margins = dpi(10), + widget = wibox.container.margin + }, + bg = color["Grey900"], + border_color = color["Grey800"], + border_width = dpi(4), + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 12) + end, + forced_width = dpi(400), + widget = wibox.container.background + } + + -- Variables for easier access and better readability + local audio_selector_margin = volume_controller:get_children_by_id("audio_selector_margin")[1] + local volume_list = volume_controller:get_children_by_id("volume_list")[1] + local audio_bg = volume_controller:get_children_by_id("audio_bg")[1] + local audio_volume = volume_controller:get_children_by_id("audio_volume")[1].center + + -- Click event for the audio dropdown + audio_selector_margin:connect_signal( + "button::press", + function() + volume_list.visible = not volume_list.visible + if volume_list.visible then + audio_bg.shape = function(cr, width, height) + gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4) + end + audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["Teal200"])) + else + audio_bg.shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 4) + end + audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["Teal200"])) + end + end + ) + + -- Variables for easier access and better readability + local mic_selector_margin = volume_controller:get_children_by_id("mic_selector_margin")[1] + local mic_list = volume_controller:get_children_by_id("mic_list")[1] + local mic_bg = volume_controller:get_children_by_id("mic_bg")[1] + local mic_volume = volume_controller:get_children_by_id("mic_volume")[1].center + + -- Click event for the microphone dropdown + mic_selector_margin:connect_signal( + "button::press", + function() + mic_list.visible = not mic_list.visible + if mic_list.visible then + mic_selector_margin.mic_bg.shape = function(cr, width, height) + gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4) + end + mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["Teal200"])) + else + mic_bg.shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 4) + end + mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["Teal200"])) + end + end + ) + + local audio_slider_margin = volume_controller:get_children_by_id("audio_volume_margin")[1].audio_volume.slider_margin.slider + + -- Volume slider change event + audio_slider_margin:connect_signal( + "property::value", + function() + local volume = audio_slider_margin.value + awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ " .. tonumber(volume) .. "%") + end + ) + + local mic_slider_margin = volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider + + -- Microphone slider change event + mic_slider_margin:connect_signal( + "property::value", + function() + local volume = mic_slider_margin.value + awful.spawn("pactl set-source-volume @DEFAULT_SOURCE@ " .. tonumber(volume) .. "%") + awesome.emit_signal("get::mic_volume", volume) + end + ) + + -- Main container + local volume_controller_container = awful.popup { + widget = wibox.container.background, + ontop = true, + bg = color["Grey900"], + stretch = false, + visible = false, + screen = s, + placement = function(c) awful.placement.align(c, { position = "top_right", margins = { right = dpi(305), top = dpi(60) } }) end, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 12) + end + } + + -- Get all audio devices from all sinks + local function get_devices() + awful.spawn.easy_async_with_shell( + [[ pactl list sinks | grep -E 'node.name|alsa.card_name' | awk '{gsub(/"/, ""); for(i = 3;i < NF;i++) printf $i " "; print $NF}' ]], + + function(stdout) + local i, j = 1, 1 + local device_list = { layout = wibox.layout.fixed.vertical } + + local node_names, alsa_names = {}, {} + for node_name in stdout:gmatch("[^\n]+") do + if (i % 2) == 0 then + table.insert(node_names, node_name) + end + i = i + 1 + end + + for alsa_name in stdout:gmatch("[^\n]+") do + if (j % 2) == 1 then + table.insert(alsa_names, alsa_name) + end + j = j + 1 + end + + for k = 1, #alsa_names, 1 do + device_list[#device_list + 1] = create_device(alsa_names[k], node_names[k], true) + end + dropdown_list_volume.volume_device_background.volume_device_list.children = device_list + end + ) + end + + get_devices() + + -- Get all input devices from all sources + local function get_input_devices() + awful.spawn.easy_async_with_shell( + [[ pactl list sources | grep -E "node.name|alsa.card_name" | awk '{gsub(/"/, ""); for(i = 3;i < NF;i++) printf $i " "; print $NF}' ]], + + function(stdout) + local i, j = 1, 1 + local device_list = { layout = wibox.layout.fixed.vertical } + + local node_names, alsa_names = {}, {} + for node_name in stdout:gmatch("[^\n]+") do + if (i % 2) == 0 then + table.insert(node_names, node_name) + end + i = i + 1 + end + + for alsa_name in stdout:gmatch("[^\n]+") do + if (j % 2) == 1 then + table.insert(alsa_names, alsa_name) + end + j = j + 1 + end + + for k = 1, #alsa_names, 1 do + device_list[#device_list + 1] = create_device(alsa_names[k], node_names[k], false) + end + dropdown_list_microphone.volume_device_background.volume_device_list.children = device_list + end + ) + end + + get_input_devices() + + -- Get microphone volume + local function get_mic_volume() + awful.spawn.easy_async_with_shell( + "./.config/awesome/src/scripts/mic.sh volume", + function(stdout) + local volume = stdout:gsub("%%", ""):gsub("\n", "") + volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider:set_value(tonumber(volume)) + if volume > 0 then + volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone.svg", color["LightBlue200"])) + else + volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"])) + end + end + ) + end + + get_mic_volume() + + -- Check if microphone is muted + local function get_mic_mute() + awful.spawn.easy_async_with_shell( + "./.config/awesome/src/scripts/mic.sh mute", + function(stdout) + if stdout:match("yes") then + volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider:set_value(tonumber(0)) + volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"])) + else + get_mic_volume() + end + end + ) + end + + get_mic_mute() + + volume_controller_container:setup { + volume_controller, + layout = wibox.layout.fixed.horizontal + } + + -- Global signal called from src.widgets.audio.lua + awesome.connect_signal( + "get::volume", + function(volume) + volume = tonumber(volume) + local icon = icondir .. "volume" + if volume < 1 then + icon = icon .. "-mute" + + elseif volume >= 1 and volume < 34 then + icon = icon .. "-low" + elseif volume >= 34 and volume < 67 then + icon = icon .. "-medium" + elseif volume >= 67 then + icon = icon .. "-high" + end + + volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.slider_margin.slider:set_value(volume) + volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Purple200"])) + end + ) + + -- Global signal called from src.widgets.audio.lua + awesome.connect_signal( + "get::volume_mute", + function(mute) + if mute then + volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "volume-mute.svg", color["Purple200"])) + end + end + ) + + awesome.connect_signal( + "get::mic_volume", + function(volume) + if volume > 0 then + volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone.svg", color["LightBlue200"])) + else + volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"])) + end + end + ) + + -- Toggle container visibility + awesome.connect_signal( + "volume_controller::toggle", + function(scr) + if scr == s then + volume_controller_container.visible = not volume_controller_container.visible + end + + end + ) + +end diff --git a/awesome/src/scripts/mic.sh b/awesome/src/scripts/mic.sh new file mode 100755 index 0000000..6f57c7f --- /dev/null +++ b/awesome/src/scripts/mic.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +SINK=$(LC_ALL=C pactl get-default-source) + +case $1 in + + "volume") + echo $(LC_ALL=C pactl get-source-volume $SINK | awk '{print $5}') + ;; + + "mute") + echo $(LC_ALL=C pactl get-source-mute $SINK) + ;; + + "toggle_mute") + $(LC_ALL=C pactl set-source-mute $SINK toggle) + ;; + + "set_volume") + $(LC_ALL=C pactl set-source-volume $SINK $2) + ;; + + "set_source") + $(LC_ALL=C pactl set-default-source $2) + ;; + +esac diff --git a/awesome/src/scripts/vol.sh b/awesome/src/scripts/vol.sh index 861450f..7877e7c 100755 --- a/awesome/src/scripts/vol.sh +++ b/awesome/src/scripts/vol.sh @@ -2,10 +2,17 @@ SINK=$(LC_ALL=C pactl get-default-sink) -if [[ $1 == "volume" ]] -then - echo $(LC_ALL=C pactl get-sink-volume $SINK | awk '{print $5}') -elif [[ $1 == "mute" ]] -then - echo $(LC_ALL=C pactl get-sink-mute $SINK) -fi +case $1 in + + "volume") + echo $(LC_ALL=C pactl get-sink-volume $SINK | awk '{print $5}') + ;; + + "mute") + echo $(LC_ALL=C pactl get-sink-mute $SINK) + ;; + + "set_sink") + $(LC_ALL=C pactl set-default-sink $2) + ;; +esac diff --git a/awesome/src/theme/colors.lua b/awesome/src/theme/colors.lua index b956a83..8b0f0ad 100644 --- a/awesome/src/theme/colors.lua +++ b/awesome/src/theme/colors.lua @@ -3,193 +3,209 @@ ----------------------------------------------------- return { - ['White'] = '#ffffffdd', - ['Black'] = '#000000', + ['White'] = '#ffffffdd', + ['Black'] = '#000000', - ['Grey50'] = '#fafafa', - ['Grey100'] = '#f5f5f5', - ['Grey200'] = '#eeeeee', - ['Grey300'] = '#e0e0e0', - ['Grey400'] = '#bdbdbd', - ['Grey500'] = '#9e9e9e', - ['Grey600'] = '#757575', - ['Grey700'] = '#616161', - ['Grey800'] = '#424242', - ['Grey900'] = '#212121', + ['Grey50'] = '#fafafa', + ['Grey100'] = '#f5f5f5', + ['Grey200'] = '#eeeeee', + ['Grey300'] = '#e0e0e0', + ['Grey400'] = '#bdbdbd', + ['Grey500'] = '#9e9e9e', + ['Grey600'] = '#757575', + ['Grey700'] = '#616161', + ['Grey800'] = '#424242', + ['Grey900'] = '#212121', - ['Red50'] = '#ffebee', - ['Red100'] = '#ffcdd2', - ['Red200'] = '#ef9a9a', - ['Red300'] = '#e57373', - ['Red400'] = '#ef5350', - ['Red500'] = '#f44336', - ['Red600'] = '#e53935', - ['Red700'] = '#d32f2f', - ['Red800'] = '#c62828', - ['Red900'] = '#b71c1c', - ['RedA100'] = '#ff8a80', - ['RedA200'] = '#ff5252', - ['RedA400'] = '#ff1744', - ['RedA700'] = '#d50000', + ['Red50'] = '#ffebee', + ['Red100'] = '#ffcdd2', + ['Red200'] = '#ef9a9a', + ['Red300'] = '#e57373', + ['Red400'] = '#ef5350', + ['Red500'] = '#f44336', + ['Red600'] = '#e53935', + ['Red700'] = '#d32f2f', + ['Red800'] = '#c62828', + ['Red900'] = '#b71c1c', + ['RedA100'] = '#ff8a80', + ['RedA200'] = '#ff5252', + ['RedA400'] = '#ff1744', + ['RedA700'] = '#d50000', - ['Pink50'] = '#fce4ec', - ['Pink100'] = '#f8bbd0', - ['Pink200'] = '#f48fb1', - ['Pink300'] = '#f06292', - ['Pink400'] = '#ec407a', - ['Pink500'] = '#e91e63', - ['Pink600'] = '#d81b60', - ['Pink700'] = '#c2185b', - ['Pink800'] = '#ad1457', - ['Pink900'] = '#880e4f', - ['PinkA100'] = '#ff80ab', - ['PinkA200'] = '#ff4081', - ['PinkA400'] = '#f50057', - ['PinkA700'] = '#c51162', + ['Pink50'] = '#fce4ec', + ['Pink100'] = '#f8bbd0', + ['Pink200'] = '#f48fb1', + ['Pink300'] = '#f06292', + ['Pink400'] = '#ec407a', + ['Pink500'] = '#e91e63', + ['Pink600'] = '#d81b60', + ['Pink700'] = '#c2185b', + ['Pink800'] = '#ad1457', + ['Pink900'] = '#880e4f', + ['PinkA100'] = '#ff80ab', + ['PinkA200'] = '#ff4081', + ['PinkA400'] = '#f50057', + ['PinkA700'] = '#c51162', - ['Blue50'] = '#e3f2fd', - ['Blue100'] = '#bbdefb', - ['Blue200'] = '#90caf9', - ['Blue300'] = '#64b5f6', - ['Blue400'] = '#42a5f5', - ['Blue500'] = '#2196f3', - ['Blue600'] = '#1e88e5', - ['Blue700'] = '#1976d2', - ['Blue800'] = '#1565c0', - ['Blue900'] = '#0d47a1', - ['BlueA100'] = '#82b1ff', - ['BlueA200'] = '#448aff', - ['BlueA400'] = '#2979ff', - ['BlueA700'] = '#2962ff', + ['Blue50'] = '#e3f2fd', + ['Blue100'] = '#bbdefb', + ['Blue200'] = '#90caf9', + ['Blue300'] = '#64b5f6', + ['Blue400'] = '#42a5f5', + ['Blue500'] = '#2196f3', + ['Blue600'] = '#1e88e5', + ['Blue700'] = '#1976d2', + ['Blue800'] = '#1565c0', + ['Blue900'] = '#0d47a1', + ['BlueA100'] = '#82b1ff', + ['BlueA200'] = '#448aff', + ['BlueA400'] = '#2979ff', + ['BlueA700'] = '#2962ff', - ['Yellow50'] = '#fffde7', - ['Yellow100'] = '#fff9c4', - ['Yellow200'] = '#fff59d', - ['Yellow300'] = '#fff176', - ['Yellow400'] = '#ffee58', - ['Yellow500'] = '#ffeb3b', - ['Yellow600'] = '#fdd835', - ['Yellow700'] = '#fbc02d', - ['Yellow800'] = '#f9a825', - ['Yellow900'] = '#f57f17', - ['YellowA100'] = '#ffff8d', - ['YellowA200'] = '#ffff00', - ['YellowA400'] = '#ffea00', - ['YellowA700'] = '#ffd600', + ['Yellow50'] = '#fffde7', + ['Yellow100'] = '#fff9c4', + ['Yellow200'] = '#fff59d', + ['Yellow300'] = '#fff176', + ['Yellow400'] = '#ffee58', + ['Yellow500'] = '#ffeb3b', + ['Yellow600'] = '#fdd835', + ['Yellow700'] = '#fbc02d', + ['Yellow800'] = '#f9a825', + ['Yellow900'] = '#f57f17', + ['YellowA100'] = '#ffff8d', + ['YellowA200'] = '#ffff00', + ['YellowA400'] = '#ffea00', + ['YellowA700'] = '#ffd600', - ['Teal50'] = '#e0f2f1', - ['Teal100'] = '#b2dfdb', - ['Teal200'] = '#80cbc4', - ['Teal300'] = '#4db6ac', - ['Teal400'] = '#26a69a', - ['Teal500'] = '#009688', - ['Teal600'] = '#00897b', - ['Teal700'] = '#00796b', - ['Teal800'] = '#00695c', - ['Teal900'] = '#004d40', - ['TealA100'] = '#a7ffeb', - ['TealA200'] = '#64ffda', - ['TealA400'] = '#1de9b6', - ['TealA700'] = '#00bfa5', + ['Teal50'] = '#e0f2f1', + ['Teal100'] = '#b2dfdb', + ['Teal200'] = '#80cbc4', + ['Teal300'] = '#4db6ac', + ['Teal400'] = '#26a69a', + ['Teal500'] = '#009688', + ['Teal600'] = '#00897b', + ['Teal700'] = '#00796b', + ['Teal800'] = '#00695c', + ['Teal900'] = '#004d40', + ['TealA100'] = '#a7ffeb', + ['TealA200'] = '#64ffda', + ['TealA400'] = '#1de9b6', + ['TealA700'] = '#00bfa5', - ['Green50'] = '#e8f5e9', - ['Green100'] = '#c8e6c9', - ['Green200'] = '#a5d6a7', - ['Green300'] = '#81c784', - ['Green400'] = '#66bb6a', - ['Green500'] = '#4caf50', - ['Green600'] = '#43a047', - ['Green700'] = '#388e3c', - ['Green800'] = '#2e7d32', - ['Green900'] = '#1b5e20', - ['GreenA100'] = '#b9f6ca', - ['GreenA200'] = '#69f0ae', - ['GreenA400'] = '#00e676', - ['GreenA700'] = '#00c853', + ['Green50'] = '#e8f5e9', + ['Green100'] = '#c8e6c9', + ['Green200'] = '#a5d6a7', + ['Green300'] = '#81c784', + ['Green400'] = '#66bb6a', + ['Green500'] = '#4caf50', + ['Green600'] = '#43a047', + ['Green700'] = '#388e3c', + ['Green800'] = '#2e7d32', + ['Green900'] = '#1b5e20', + ['GreenA100'] = '#b9f6ca', + ['GreenA200'] = '#69f0ae', + ['GreenA400'] = '#00e676', + ['GreenA700'] = '#00c853', - ['Orange50'] = '#fff3e0', - ['Orange100'] = '#ffe0b2', - ['Orange200'] = '#ffcc80', - ['Orange300'] = '#ffb74d', - ['Orange400'] = '#ffa726', - ['Orange500'] = '#ff9800', - ['Orange600'] = '#fb8c00', - ['Orange700'] = '#f57c00', - ['Orange800'] = '#ef6c00', - ['Orange900'] = '#e65100', - ['OrangeA100'] = '#ffd180', - ['OrangeA200'] = '#ffab40', - ['OrangeA400'] = '#ff9100', - ['OrangeA700'] = '#ff6d00', + ['Orange50'] = '#fff3e0', + ['Orange100'] = '#ffe0b2', + ['Orange200'] = '#ffcc80', + ['Orange300'] = '#ffb74d', + ['Orange400'] = '#ffa726', + ['Orange500'] = '#ff9800', + ['Orange600'] = '#fb8c00', + ['Orange700'] = '#f57c00', + ['Orange800'] = '#ef6c00', + ['Orange900'] = '#e65100', + ['OrangeA100'] = '#ffd180', + ['OrangeA200'] = '#ffab40', + ['OrangeA400'] = '#ff9100', + ['OrangeA700'] = '#ff6d00', - ['DeepOrange50'] = '#fbe9e7', - ['DeepOrange100'] = '#ffccbc', - ['DeepOrange200'] = '#ffab91', - ['DeepOrange300'] = '#ff8a65', - ['DeepOrange400'] = '#ff7043', - ['DeepOrange500'] = '#ff5722', - ['DeepOrange600'] = '#f4511e', - ['DeepOrange700'] = '#e64a19', - ['DeepOrange800'] = '#d84315', - ['DeepOrange900'] = '#bf360c', - ['DeepOrangeA100'] = '#ff9e80', - ['DeepOrangeA200'] = '#ff6e40', - ['DeepOrangeA400'] = '#ff3d00', - ['DeepOrangeA700'] = '#dd2c00', + ['DeepOrange50'] = '#fbe9e7', + ['DeepOrange100'] = '#ffccbc', + ['DeepOrange200'] = '#ffab91', + ['DeepOrange300'] = '#ff8a65', + ['DeepOrange400'] = '#ff7043', + ['DeepOrange500'] = '#ff5722', + ['DeepOrange600'] = '#f4511e', + ['DeepOrange700'] = '#e64a19', + ['DeepOrange800'] = '#d84315', + ['DeepOrange900'] = '#bf360c', + ['DeepOrangeA100'] = '#ff9e80', + ['DeepOrangeA200'] = '#ff6e40', + ['DeepOrangeA400'] = '#ff3d00', + ['DeepOrangeA700'] = '#dd2c00', - ['Purple50'] = '#F3E5F5', - ['Purple100'] = '#E1BEE7', - ['Purple200'] = '#CE93D8', - ['Purple300'] = '#BA68C8', - ['Purple400'] = '#AB47BC', - ['Purple500'] = '#9C27B0', - ['Purple600'] = '#8E24AA', - ['Purple700'] = '#7B1FA2', - ['Purple800'] = '#6A1B9A', - ['Purple900'] = '#4A148C', - ['PurpleA100'] = '#EA80FC', - ['PurpleA200'] = '#E040FB', - ['PurpleA500'] = '#D500F9', - ['PurpleA700'] = '#AA00FF', + ['Purple50'] = '#F3E5F5', + ['Purple100'] = '#E1BEE7', + ['Purple200'] = '#CE93D8', + ['Purple300'] = '#BA68C8', + ['Purple400'] = '#AB47BC', + ['Purple500'] = '#9C27B0', + ['Purple600'] = '#8E24AA', + ['Purple700'] = '#7B1FA2', + ['Purple800'] = '#6A1B9A', + ['Purple900'] = '#4A148C', + ['PurpleA100'] = '#EA80FC', + ['PurpleA200'] = '#E040FB', + ['PurpleA500'] = '#D500F9', + ['PurpleA700'] = '#AA00FF', - ['DeepPurple50'] = '#EDE7F6', - ['DeepPurple100'] = '#D1C4E9', - ['DeepPurple200'] = '#B39DDB', - ['DeepPurple300'] = '#9575CD', - ['DeepPurple400'] = '#7E57C2', - ['DeepPurple500'] = '#673AB7', - ['DeepPurple600'] = '#5E35B1', - ['DeepPurple700'] = '#512DA8', - ['DeepPurple800'] = '#4527A0', - ['DeepPurple900'] = '#311B92', - ['DeepPurpleA100'] = '#B388FF', - ['DeepPurpleA200'] = '#7C4DFF', - ['DeepPurpleA400'] = '#651FFF', - ['DeepPurpleA700'] = '#6200EA', + ['DeepPurple50'] = '#EDE7F6', + ['DeepPurple100'] = '#D1C4E9', + ['DeepPurple200'] = '#B39DDB', + ['DeepPurple300'] = '#9575CD', + ['DeepPurple400'] = '#7E57C2', + ['DeepPurple500'] = '#673AB7', + ['DeepPurple600'] = '#5E35B1', + ['DeepPurple700'] = '#512DA8', + ['DeepPurple800'] = '#4527A0', + ['DeepPurple900'] = '#311B92', + ['DeepPurpleA100'] = '#B388FF', + ['DeepPurpleA200'] = '#7C4DFF', + ['DeepPurpleA400'] = '#651FFF', + ['DeepPurpleA700'] = '#6200EA', - ['LightBlue50'] = '#E1F5FE', - ['LightBlue100'] = '#B3E5FC', - ['LightBlue200'] = '#81D4FA', - ['LightBlue300'] = '#4FC3F7', - ['LightBlue400'] = '#29B6F6', - ['LightBlue500'] = '#03A9F4', - ['LightBlue600'] = '#039BE5', - ['LightBlue700'] = '#0288D1', - ['LightBlue800'] = '#0277BD', - ['LightBlue900'] = '#01579B', - ['LightBlueA100'] = '#80D8FF', - ['LightBlueA200'] = '#40C4FF', - ['LightBlueA400'] = '#00B0FF', - ['LightBlueA700'] = '#0091EA', + ['LightBlue50'] = '#E1F5FE', + ['LightBlue100'] = '#B3E5FC', + ['LightBlue200'] = '#81D4FA', + ['LightBlue300'] = '#4FC3F7', + ['LightBlue400'] = '#29B6F6', + ['LightBlue500'] = '#03A9F4', + ['LightBlue600'] = '#039BE5', + ['LightBlue700'] = '#0288D1', + ['LightBlue800'] = '#0277BD', + ['LightBlue900'] = '#01579B', + ['LightBlueA100'] = '#80D8FF', + ['LightBlueA200'] = '#40C4FF', + ['LightBlueA400'] = '#00B0FF', + ['LightBlueA700'] = '#0091EA', - ['BlueGrey50'] = '#ECEFF1', - ['BlueGrey100'] = '#CFD8DC', - ['BlueGrey200'] = '#B0BEC5', - ['BlueGrey300'] = '#90A4AE', - ['BlueGrey400'] = '#78909C', - ['BlueGrey500'] = '#607D8B', - ['BlueGrey600'] = '#546E7A', - ['BlueGrey700'] = '#455A64', - ['BlueGrey800'] = '#37474F', - ['BlueGrey900'] = '#263238' + ['Cyan50'] = '#E0F7FA', + ['Cyan100'] = '#B2EBF2', + ['Cyan200'] = '#80DEEA', + ['Cyan300'] = '#4DD0E1', + ['Cyan400'] = '#26C6DA', + ['Cyan500'] = '#00BCD4', + ['Cyan600'] = '#00ACC1', + ['Cyan700'] = '#0097A7', + ['Cyan800'] = '#00838F', + ['Cyan900'] = '#006064', + ['CyanA100'] = '#84FFFF', + ['CyanA200'] = '#18FFFF', + ['CyanA400'] = '#00E5FF', + ['CyanA700'] = '#00B8D4', + + + ['BlueGrey50'] = '#ECEFF1', + ['BlueGrey100'] = '#CFD8DC', + ['BlueGrey200'] = '#B0BEC5', + ['BlueGrey300'] = '#90A4AE', + ['BlueGrey400'] = '#78909C', + ['BlueGrey500'] = '#607D8B', + ['BlueGrey600'] = '#546E7A', + ['BlueGrey700'] = '#455A64', + ['BlueGrey800'] = '#37474F', + ['BlueGrey900'] = '#263238' } diff --git a/awesome/src/theme/init.lua b/awesome/src/theme/init.lua index 8c1ef8a..c2a3f4c 100644 --- a/awesome/src/theme/init.lua +++ b/awesome/src/theme/init.lua @@ -23,15 +23,14 @@ beautiful.wallpaper = user_vars.wallpaper screen.connect_signal( 'request::wallpaper', function(s) - -- If wallpaper is a function, call it with the screen - if beautiful.wallpaper then - if type(beautiful.wallpaper) == 'string' then - gears.wallpaper.maximized(beautiful.wallpaper, s) - else - beautiful.wallpaper(s) - end + if beautiful.wallpaper then + if type(beautiful.wallpaper) == 'string' then + gears.wallpaper.maximized(beautiful.wallpaper, s) + else + beautiful.wallpaper(s) end end +end ) beautiful.init(Theme) diff --git a/awesome/src/theme/theme_variables.lua b/awesome/src/theme/theme_variables.lua index 0b2f181..31e5004 100644 --- a/awesome/src/theme/theme_variables.lua +++ b/awesome/src/theme/theme_variables.lua @@ -40,31 +40,22 @@ Theme.menu_fg_focus = color["White"] Theme.menu_border_color = color["Grey800"] Theme.menu_border_width = dpi(0) Theme.menu_shape = function(cr, width, heigth) - gears.shape.rounded_rect(cr, width, heigth, 5) + gears.shape.rounded_rect(cr, width, heigth, 5) end Theme.taglist_fg_focus = color["Grey900"] Theme.taglist_bg_focus = color["White"] -Theme.tooltip_border_color = color["Grey900"] -Theme.tooltip_bg = color["Grey800"] -Theme.tooltip_fg = color["White"] -Theme.tooltip_border_width = dpi(0) +Theme.tooltip_border_color = color["Grey800"] +Theme.tooltip_bg = color["Grey900"] +Theme.tooltip_fg = color["YellowA200"] +Theme.tooltip_border_width = dpi(4) +Theme.tooltip_gaps = dpi(15) Theme.tooltip_shape = function(cr, width, heigth) - gears.shape.rounded_rect(cr, width, heigth, 5) + gears.shape.rounded_rect(cr, width, heigth, 5) end -Theme.notification_bg = color["Grey900"] -Theme.notification_fg = color["White"] -Theme.notification_border_width = dpi(0) -Theme.notification_border_color = color["Grey900"] -Theme.notification_shape = function(cr, width, heigth) - gears.shape.rounded_rect(cr, width, heigth, 10) -end -Theme.notification_margin = dpi(10) -Theme.notification_max_width = dpi(400) -Theme.notification_max_height = dpi(1000) -Theme.notification_icon_size = dpi(40) +Theme.notification_spacing = dpi(20) Theme.titlebar_close_button_normal = icondir .. "close.svg" Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" @@ -79,7 +70,7 @@ Theme.hotkeys_bg = color["Grey900"] Theme.hotkeys_fg = color["White"] Theme.hotkeys_border_width = 0 Theme.hotkeys_shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 10) + gears.shape.rounded_rect(cr, width, height, 10) end Theme.hotkeys_description_font = user_vars.font.bold @@ -87,9 +78,14 @@ Theme.hotkeys_description_font = user_vars.font.bold local layout_path = Theme_path .. "../assets/layout/" -- Here are the icons for the layouts defined, if you want to add more layouts go to main/layouts.lua -Theme.layout_floating = gears.color.recolor_image(layout_path .. "floating.svg", color["Grey900"]) -Theme.layout_tile = gears.color.recolor_image(layout_path .. "tile.svg", color["Grey900"]) ---Theme.layout_dwindle = gears.color.recolor_image(layout_path .. "dwindle.svg", color["Grey900"]) ---Theme.layout_fairh = gears.color.recolor_image(layout_path .. "fairh.svg", color["Grey900"]) ---Theme.layout_fullscreen = gears.color.recolor_image(layout_path .. "fullscreen.svg", color["Grey900"]) ---Theme.layout_max = gears.color.recolor_image(layout_path .. "max.svg", color["Grey900"]) +Theme.layout_floating = layout_path .. "floating.svg" +Theme.layout_tile = layout_path .. "tile.svg" +Theme.layout_dwindle = layout_path .. "dwindle.svg" +Theme.layout_fairh = layout_path .. "fairh.svg" +Theme.layout_fairv = layout_path .. "fairv.svg" +Theme.layout_fullscreen = layout_path .. "fullscreen.svg" +Theme.layout_max = layout_path .. "max.svg" +Theme.layout_cornerne = layout_path .. "cornerne.svg" +Theme.layout_cornernw = layout_path .. "cornernw.svg" +Theme.layout_cornerse = layout_path .. "cornerse.svg" +Theme.layout_cornersw = layout_path .. "cornersw.svg" diff --git a/awesome/src/theme/user_variables.lua b/awesome/src/theme/user_variables.lua index 8c8e998..af0494f 100644 --- a/awesome/src/theme/user_variables.lua +++ b/awesome/src/theme/user_variables.lua @@ -8,84 +8,98 @@ local home = os.getenv("HOME") -- If you want different default programs, wallpaper path or modkey; edit this file. user_vars = { - -- Autotiling layouts - layouts = { - awful.layout.suit.tile, - awful.layout.suit.floating, - awful.layout.suit.fair, - }, + -- Autotiling layouts + layouts = { + awful.layout.suit.tile, + awful.layout.suit.tile.left, + awful.layout.suit.tile.bottom, + awful.layout.suit.tile.top, + awful.layout.suit.floating, + awful.layout.suit.fair, + awful.layout.suit.fair.horizontal, + awful.layout.suit.corner.nw, + awful.layout.suit.corner.ne, + awful.layout.suit.corner.sw, + awful.layout.suit.corner.se, + awful.layout.suit.magnifier, + awful.layout.suit.max, + awful.layout.suit.max.fullscreen, + awful.layout.suit.spiral.dwindle, + }, - -- Icon theme from /usr/share/icons - icon_theme = "Papirus-Dark", + -- Icon theme from /usr/share/icons + icon_theme = "Papirus-Dark", - -- Write the terminal command to start anything here - autostart = { - "picom --experimental-backends", - "xfce4-power-manager", - "light-locker --lock-on-suspend --lock-on-lid &", - "flatpak run com.spotify.Client", - "discord", - "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1" - }, + -- Write the terminal command to start anything here + autostart = { + "picom --experimental-backends", + "xfce4-power-manager", + "light-locker --lock-on-suspend --lock-on-lid &", + "flatpak run com.spotify.Client", + "discord", + "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1", + "setxkbmap -option caps:swapescape" + }, - -- Type 'ip a' and check your wlan and ethernet name - network = { - wlan = "wlo1", - ethernet = "eno1" - }, + -- Type 'ip a' and check your wlan and ethernet name + network = { + wlan = "wlo1", + ethernet = "eno1" + }, - -- Set your font with this format: - font = { - regular = "JetBrainsMono Nerd Font, 14", - bold = "JetBrainsMono Nerd Font, bold 14", - extrabold = "JetBrainsMono Nerd Font, ExtraBold 14" - }, + -- Set your font with this format: + font = { + regular = "JetBrainsMono Nerd Font, 14", + bold = "JetBrainsMono Nerd Font, bold 14", + extrabold = "JetBrainsMono Nerd Font, ExtraBold 14", + specify = "JetBrainsMono Nerd Font" + }, - -- This is your default Terminal - terminal = "alacritty", + -- This is your default Terminal + terminal = "alacritty", - -- This is the modkey 'mod4' = Super/Mod/WindowsKey, 'mod3' = alt... - modkey = "Mod4", + -- This is the modkey 'mod4' = Super/Mod/WindowsKey, 'mod3' = alt... + modkey = "Mod4", - -- place your wallpaper at this path with this name, you could also try to change the path - wallpaper = home .. "/.config/awesome/src/assets/fuji.jpg", + -- place your wallpaper at this path with this name, you could also try to change the path + wallpaper = home .. "/.config/awesome/src/assets/fuji.jpg", - -- Naming scheme for the powermenu, userhost = "user@hostname", fullname = "Firstname Surname", something else ... - namestyle = "userhost", + -- Naming scheme for the powermenu, userhost = "user@hostname", fullname = "Firstname Surname", something else ... + namestyle = "userhost", - -- List every Keyboard layout you use here comma seperated. (run localectl list-keymaps to list all averiable keymaps) - kblayout = { "de", "ru" }, + -- List every Keyboard layout you use here comma seperated. (run localectl list-keymaps to list all averiable keymaps) + kblayout = { "de", "ru" }, - -- Your filemanager that opens with super+e - file_manager = "nemo", + -- Your filemanager that opens with super+e + file_manager = "thunar", - -- Screenshot program to make a screenshot when print is hit - screenshot_program = "flameshot gui", + -- Screenshot program to make a screenshot when print is hit + screenshot_program = "flameshot gui", - -- If you use the dock here is how you control its size - dock_icon_size = dpi(50), + -- If you use the dock here is how you control its size + dock_icon_size = dpi(50), - -- Add your programs exactly like in this example. - -- First entry has to be how you would start the program in the terminal (just try it if you dont know yahoo it) - -- Second can be what ever the fuck you want it to be (will be the displayed name if you hover over it) - -- For steam games please use this format (look in .local/share/applications for the .desktop file, that will contain the number you need) - -- {"394360", "Name", true} true will tell the func that it's a steam game - -- Use xprop | grep WM_CLASS and use the *SECOND* string - -- { WM_CLASS, program, name, isSteam } - dock_programs = { - { "Alacritty", "alacritty", "Alacritty" }, - { "firefox", "firefox", "Firefox" }, - { "discord", "discord", "Discord" }, - { "Spotify", "flatpak run com.spotify.Client", "Spotify" }, - { "Code", "code", "Visual Studio Code" }, - { "processing-app-Base", "arduino", "Arduino IDE" }, - { "zoom", "zoom", "Zoom" }, - { "Thunderbird", "thunderbird", "Thunderbird" }, - { "Mattermost", "mattermost-desktop", "Mattermost" }, - { "Blender", "blender", "Blender" }, - { "Steam", "steam", "Steam" }, - { "FreeCAD", "freecad", "FreeCAD" }, - { "Nemo", "nemo", "Dateien" }, - { "Paradox Launcher", "394360", "Hearts of Iron 4", true } - } + -- Add your programs exactly like in this example. + -- First entry has to be how you would start the program in the terminal (just try it if you dont know yahoo it) + -- Second can be what ever the fuck you want it to be (will be the displayed name if you hover over it) + -- For steam games please use this format (look in .local/share/applications for the .desktop file, that will contain the number you need) + -- {"394360", "Name", true} true will tell the func that it's a steam game + -- Use xprop | grep WM_CLASS and use the *SECOND* string + -- { WM_CLASS, program, name, user_icon, isSteam } + dock_programs = { + { "Alacritty", "alacritty", "Alacritty" }, + { "firefox", "firefox", "Firefox" }, + { "discord", "discord", "Discord" }, + { "Spotify", "flatpak run com.spotify.Client", "Spotify" }, + { "Code", "code", "Visual Studio Code" }, + { "processing-app-Base", "arduino", "Arduino IDE" }, + { "Zoom", "flatpak run us.zoom.Zoom", "Zoom" }, + { "Thunderbird", "thunderbird", "Thunderbird" }, + { "Mattermost", "mattermost-desktop", "Mattermost" }, + { "Blender", "blender", "Blender" }, + { "Steam", "steam", "Steam" }, + { "FreeCAD", "freecad", "FreeCAD" }, + { "Thunar", "thunar", "Dateien" }, + { "Windows", "virsh start Windows_11", "Windows 11", "/home/crylia/Bilder/windows.png", false, 50 } + } } diff --git a/awesome/src/tools/auto_starter.lua b/awesome/src/tools/auto_starter.lua index 3dd73a5..dd13865 100644 --- a/awesome/src/tools/auto_starter.lua +++ b/awesome/src/tools/auto_starter.lua @@ -1,7 +1,7 @@ local awful = require("awful") return function(table) - for i, t in ipairs(table) do - awful.spawn.with_shell(t); + for _, t in ipairs(table) do + awful.spawn(t); end end diff --git a/awesome/src/tools/icon_handler.lua b/awesome/src/tools/icon_handler.lua index 0f46f98..b6cbeea 100644 --- a/awesome/src/tools/icon_handler.lua +++ b/awesome/src/tools/icon_handler.lua @@ -8,74 +8,74 @@ local icon_cache = {} -- TODO: try with more icon themes function Get_icon(theme, client, program_string, class_string, is_steam) - client = client or nil - program_string = program_string or nil - class_string = class_string or nil - is_steam = is_steam or nil + client = client or nil + program_string = program_string or nil + class_string = class_string or nil + is_steam = is_steam or nil - if theme and (client or program_string or class_string) then - local clientName - if is_steam then - clientName = "steam_icon_" .. tostring(client) .. ".svg" - elseif client then - if client.class then - clientName = string.lower(client.class:gsub(" ", "")) .. ".svg" - elseif client.name then - clientName = string.lower(client.name:gsub(" ", "")) .. ".svg" - else - if client.icon then - return client.icon - else - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" - end - end + if theme and (client or program_string or class_string) then + local clientName + if is_steam then + clientName = "steam_icon_" .. tostring(client) .. ".svg" + elseif client then + if client.class then + clientName = string.lower(client.class:gsub(" ", "")) .. ".svg" + elseif client.name then + clientName = string.lower(client.name:gsub(" ", "")) .. ".svg" + else + if client.icon then + return client.icon else - if program_string then - clientName = program_string .. ".svg" - else - clientName = class_string .. ".svg" - end - end - - for index, icon in ipairs(icon_cache) do - if icon:match(clientName) then - return icon - end - end - - local resolutions = { "128x128", "96x96", "64x64", "48x48", "42x42", "32x32", "24x24", "16x16" } - for i, res in ipairs(resolutions) do - local iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" - local ioStream = io.open(iconDir .. clientName, "r") - if ioStream ~= nil then - icon_cache[#icon_cache + 1] = iconDir .. clientName - return iconDir .. clientName - else - clientName = clientName:gsub("^%l", string.upper) - iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" - ioStream = io.open(iconDir .. clientName, "r") - if ioStream ~= nil then - icon_cache[#icon_cache + 1] = iconDir .. clientName - return iconDir .. clientName - elseif not class_string then - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" - else - clientName = class_string .. ".svg" - iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" - ioStream = io.open(iconDir .. clientName, "r") - if ioStream ~= nil then - icon_cache[#icon_cache + 1] = iconDir .. clientName - return iconDir .. clientName - else - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" - end - end - end - end - if client then - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" + return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" end + end + else + if program_string then + clientName = program_string .. ".svg" + else + clientName = class_string .. ".svg" + end end + + for index, icon in ipairs(icon_cache) do + if icon:match(clientName) then + return icon + end + end + + local resolutions = { "128x128", "96x96", "64x64", "48x48", "42x42", "32x32", "24x24", "16x16" } + for i, res in ipairs(resolutions) do + local iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" + local ioStream = io.open(iconDir .. clientName, "r") + if ioStream ~= nil then + icon_cache[#icon_cache + 1] = iconDir .. clientName + return iconDir .. clientName + else + clientName = clientName:gsub("^%l", string.upper) + iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" + ioStream = io.open(iconDir .. clientName, "r") + if ioStream ~= nil then + icon_cache[#icon_cache + 1] = iconDir .. clientName + return iconDir .. clientName + elseif not class_string then + return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" + else + clientName = class_string .. ".svg" + iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" + ioStream = io.open(iconDir .. clientName, "r") + if ioStream ~= nil then + icon_cache[#icon_cache + 1] = iconDir .. clientName + return iconDir .. clientName + else + return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" + end + end + end + end + if client then + return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" + end + end end --———————————No swiches?——————————— diff --git a/awesome/src/widgets/audio.lua b/awesome/src/widgets/audio.lua index 4933ac3..e3e0023 100644 --- a/awesome/src/widgets/audio.lua +++ b/awesome/src/widgets/audio.lua @@ -14,7 +14,7 @@ require("src.core.signals") local icondir = awful.util.getdir("config") .. "src/assets/icons/audio/" -- Returns the audio widget -return function() +return function(s) local audio_widget = wibox.widget { { @@ -78,6 +78,7 @@ return function() end audio_widget.container.audio_layout.label:set_text(volume .. "%") audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Grey900"])) + awesome.emit_signal("get::volume", volume) end ) end @@ -90,8 +91,10 @@ return function() audio_widget.container.audio_layout.label.visible = false audio_widget.container:set_right(0) audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", color["Grey900"])) + awesome.emit_signal("get::volume_mute", true) else audio_widget.container:set_right(10) + awesome.emit_signal("get::volume_mute", false) get_volume() end end @@ -104,20 +107,18 @@ return function() audio_widget:connect_signal( "button::press", function() - awesome.emit_signal("widget::volume") - --awesome.emit_signal("module::volume_osd:show", true) awesome.emit_signal("module::slider:update") awesome.emit_signal("widget::volume_osd:rerun") - awesome.emit_signal("volume_controller::toggle") + awesome.emit_signal("volume_controller::toggle", s) end ) - awesome.connect_signal( - "widget::volume", - function(c) - check_muted() - end - ) + gears.timer { + timeout = 0.5, + call_now = true, + autostart = true, + callback = check_muted + } check_muted() return audio_widget diff --git a/awesome/src/widgets/battery.lua b/awesome/src/widgets/battery.lua index 53c37b8..5093e57 100644 --- a/awesome/src/widgets/battery.lua +++ b/awesome/src/widgets/battery.lua @@ -17,185 +17,185 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/battery/" -- Returns the battery widget return function() - local battery_widget = wibox.widget { + local battery_widget = wibox.widget { + { + { { + { { - { - { - { - id = "icon", - image = gears.color.recolor_image(icondir .. "battery-unknown.svg", "#212121"), - widget = wibox.widget.imagebox, - resize = false - }, - id = "icon_layout", - widget = wibox.container.place - }, - id = "icon_margin", - top = dpi(2), - widget = wibox.container.margin - }, - spacing = dpi(10), - { - visible = false, - align = 'center', - valign = 'center', - id = "label", - widget = wibox.widget.textbox - }, - id = "battery_layout", - layout = wibox.layout.fixed.horizontal + id = "icon", + image = gears.color.recolor_image(icondir .. "battery-unknown.svg", "#212121"), + widget = wibox.widget.imagebox, + resize = false }, - id = "container", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin + id = "icon_layout", + widget = wibox.container.place + }, + id = "icon_margin", + top = dpi(2), + widget = wibox.container.margin }, - bg = color["Purple200"], - fg = color["Grey900"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } + spacing = dpi(10), + { + visible = false, + align = 'center', + valign = 'center', + id = "label", + widget = wibox.widget.textbox + }, + id = "battery_layout", + layout = wibox.layout.fixed.horizontal + }, + id = "container", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = color["Purple200"], + fg = color["Grey900"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } - local battery_tooltip = awful.tooltip { - objects = { battery_widget }, - text = "", - mode = "inside", - preferred_alignments = "middle", - margins = dpi(10) - } + local battery_tooltip = awful.tooltip { + objects = { battery_widget }, + text = "", + mode = "inside", + preferred_alignments = "middle", + margins = dpi(10) + } - local get_battery_info = function() - awful.spawn.easy_async_with_shell( - [[ upower -i $(upower -e | grep BAT) | grep "time to " ]], - function(stdout) - if stdout == nil or stdout == '' then - battery_tooltip:set_text('No Battery Found') - return - end - local rem_time = "" - if stdout:match("hour") then - rem_time = "Hours" - else - rem_time = "Minutes" - end - local bat_time = stdout:match("%d+,%d") or stdout:match("%d+.%d") or "" - if stdout:match("empty") then - battery_tooltip:set_text("Remaining battery time: " .. bat_time .. " " .. rem_time) - elseif stdout:match("time to full") then - battery_tooltip:set_text("Battery fully charged in: " .. bat_time .. " " .. rem_time) - end - end - ) + local get_battery_info = function() + awful.spawn.easy_async_with_shell( + [[ upower -i $(upower -e | grep BAT) | grep "time to " ]], + function(stdout) + if stdout == nil or stdout == '' then + battery_tooltip:set_text('No Battery Found') + return + end + local rem_time = "" + if stdout:match("hour") then + rem_time = "Hours" + else + rem_time = "Minutes" + end + local bat_time = stdout:match("%d+,%d") or stdout:match("%d+.%d") or "" + if stdout:match("empty") then + battery_tooltip:set_text("Remaining battery time: " .. bat_time .. " " .. rem_time) + elseif stdout:match("time to full") then + battery_tooltip:set_text("Battery fully charged in: " .. bat_time .. " " .. rem_time) + end end + ) + end + get_battery_info() + + local last_battery_check = os.time() + local notify_critical_battery = true + + local battery_warning = function() + naughty.notification { + icon = gears.color.recolor_image(icondir .. "battery-alert.svg", color["White"]), + app_name = "System notification", + title = "Battery is low", + message = "Battery is almost empty", + urgency = "critical" + } + end + + local update_battery = function(status) + awful.spawn.easy_async_with_shell( + [[sh -c "upower -i $(upower -e | grep BAT) | grep percentage | awk '{print \$2}' |tr -d '\n%'"]], + function(stdout) + local battery_percentage = tonumber(stdout) + + if not battery_percentage then + return + end + + battery_widget.container.battery_layout.spacing = dpi(5) + battery_widget.container.battery_layout.label.visible = true + battery_widget.container.battery_layout.label:set_text(battery_percentage .. '%') + + local icon = 'battery' + + if status == 'fully-charged' or status == 'charging' and battery_percentage == 100 then + icon = icon .. '-' .. 'charging' + battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121"))) + return + end + + if battery_percentage > 0 and battery_percentage < 10 and status == 'discharging' then + icon = icon .. '-' .. 'alert' + if (os.difftime(os.time(), last_battery_check) > 300 or notify_critical_battery) then + last_battery_check = os.time() + notify_critical_battery = false + battery_warning() + end + battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121"))) + return + end + + if battery_percentage > 0 and battery_percentage < 10 then + icon = icon .. '-' .. status .. '-' .. 'outline' + elseif battery_percentage >= 10 and battery_percentage < 20 then + icon = icon .. '-' .. status .. '-' .. '10' + elseif battery_percentage >= 20 and battery_percentage < 30 then + icon = icon .. '-' .. status .. '-' .. '20' + elseif battery_percentage >= 30 and battery_percentage < 40 then + icon = icon .. '-' .. status .. '-' .. '30' + elseif battery_percentage >= 40 and battery_percentage < 50 then + icon = icon .. '-' .. status .. '-' .. '40' + elseif battery_percentage >= 50 and battery_percentage < 60 then + icon = icon .. '-' .. status .. '-' .. '50' + elseif battery_percentage >= 60 and battery_percentage < 70 then + icon = icon .. '-' .. status .. '-' .. '60' + elseif battery_percentage >= 70 and battery_percentage < 80 then + icon = icon .. '-' .. status .. '-' .. '70' + elseif battery_percentage >= 80 and battery_percentage < 90 then + icon = icon .. '-' .. status .. '-' .. '80' + elseif battery_percentage >= 90 and battery_percentage < 100 then + icon = icon .. '-' .. status .. '-' .. '90' + end + + battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121"))) + + end + ) + end + + Hover_signal(battery_widget, color["Purple200"]) + + battery_widget:connect_signal( + 'button::press', + function() + awful.spawn("xfce4-power-manager-settings") + end + ) + + battery_widget:connect_signal( + "mouse::enter", + function() get_battery_info() + end + ) - local last_battery_check = os.time() - local notify_critical_battery = true - - local battery_warning = function() - naughty.notify({ - icon = gears.color.recolor_image(icondir .. "battery-alert.svg", color["White"]), - app_name = "System notification", - title = "Battery is low", - message = "Battery is almost battery_labelempty", - urgency = "critical" - }) + watch( + [[sh -c "upower -i $(upower -e | grep BAT) | grep state | awk '{print \$2}' | tr -d '\n'"]], + 5, + function(widget, stdout) + local status = stdout:gsub('%\n', '') + if status == nil or status == '' then + battery_widget.container.battery_layout.spacing = dpi(0) + battery_widget.container.battery_layout.label.visible = false + battery_tooltip:set_text('No battery found') + battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. 'battery-off' .. '.svg', "#212121"))) end + update_battery(status) + end + ) - local update_battery = function(status) - awful.spawn.easy_async_with_shell( - [[sh -c "upower -i $(upower -e | grep BAT) | grep percentage | awk '{print \$2}' |tr -d '\n%'"]], - function(stdout) - local battery_percentage = tonumber(stdout) - - if not battery_percentage then - return - end - - battery_widget.container.battery_layout.spacing = dpi(5) - battery_widget.container.battery_layout.label.visible = true - battery_widget.container.battery_layout.label:set_text(battery_percentage .. '%') - - local icon = 'battery' - - if status == 'fully-charged' or status == 'charging' and battery_percentage == 100 then - icon = icon .. '-' .. 'charging' - battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121"))) - return - end - - if battery_percentage > 0 and battery_percentage < 10 and status == 'discharging' then - icon = icon .. '-' .. 'alert' - if (os.difftime(os.time(), last_battery_check) > 300 or notify_critical_battery) then - last_battery_check = os.time() - notify_critical_battery = false - battery_warning() - end - battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121"))) - return - end - - if battery_percentage > 0 and battery_percentage < 10 then - icon = icon .. '-' .. status .. '-' .. 'outline' - elseif battery_percentage >= 10 and battery_percentage < 20 then - icon = icon .. '-' .. status .. '-' .. '10' - elseif battery_percentage >= 20 and battery_percentage < 30 then - icon = icon .. '-' .. status .. '-' .. '20' - elseif battery_percentage >= 30 and battery_percentage < 40 then - icon = icon .. '-' .. status .. '-' .. '30' - elseif battery_percentage >= 40 and battery_percentage < 50 then - icon = icon .. '-' .. status .. '-' .. '40' - elseif battery_percentage >= 50 and battery_percentage < 60 then - icon = icon .. '-' .. status .. '-' .. '50' - elseif battery_percentage >= 60 and battery_percentage < 70 then - icon = icon .. '-' .. status .. '-' .. '60' - elseif battery_percentage >= 70 and battery_percentage < 80 then - icon = icon .. '-' .. status .. '-' .. '70' - elseif battery_percentage >= 80 and battery_percentage < 90 then - icon = icon .. '-' .. status .. '-' .. '80' - elseif battery_percentage >= 90 and battery_percentage < 100 then - icon = icon .. '-' .. status .. '-' .. '90' - end - - battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121"))) - - end - ) - end - - Hover_signal(battery_widget, color["Purple200"]) - - battery_widget:connect_signal( - 'button::press', - function() - awful.spawn("xfce4-power-manager-settings") - end - ) - - battery_widget:connect_signal( - "mouse::enter", - function() - get_battery_info() - end - ) - - watch( - [[sh -c "upower -i $(upower -e | grep BAT) | grep state | awk '{print \$2}' | tr -d '\n'"]], - 5, - function(widget, stdout) - local status = stdout:gsub('%\n', '') - if status == nil or status == '' then - battery_widget.container.battery_layout.spacing = dpi(0) - battery_widget.container.battery_layout.label.visible = false - battery_tooltip:set_text('No battery found') - battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. 'battery-off' .. '.svg', "#212121"))) - end - update_battery(status) - end - ) - - return battery_widget + return battery_widget end diff --git a/awesome/src/widgets/bluetooth.lua b/awesome/src/widgets/bluetooth.lua index 07dc109..495fe4e 100644 --- a/awesome/src/widgets/bluetooth.lua +++ b/awesome/src/widgets/bluetooth.lua @@ -16,116 +16,116 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/bluetooth/" -- Returns the bluetooth widget return function() - local bluetooth_widget = wibox.widget { + local bluetooth_widget = wibox.widget { + { + { { - { - { - id = "icon", - image = gears.color.recolor_image(icondir .. "bluetooth-off.svg"), - widget = wibox.widget.imagebox, - resize = false - }, - id = "icon_layout", - widget = wibox.container.place - }, - id = "icon_margin", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin + id = "icon", + image = gears.color.recolor_image(icondir .. "bluetooth-off.svg"), + widget = wibox.widget.imagebox, + resize = false }, - bg = color["Blue200"], - fg = color["Grey900"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } + id = "icon_layout", + widget = wibox.container.place + }, + id = "icon_margin", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = color["Blue200"], + fg = color["Grey900"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } - local bluetooth_tooltip = awful.tooltip { - objects = { bluetooth_widget }, - text = "", - mode = "inside", - preferred_alignments = "middle", - margins = dpi(10) - } + local bluetooth_tooltip = awful.tooltip { + objects = { bluetooth_widget }, + text = "", + mode = "inside", + preferred_alignments = "middle", + margins = dpi(10) + } - local bluetooth_state = "off" - local connected_device = "nothing" + local bluetooth_state = "off" + local connected_device = "nothing" - awful.widget.watch( - "rfkill list bluetooth", - 5, - function(_, stdout) - local icon = icondir .. "bluetooth" - if stdout:match('Soft blocked: yes') or stdout:gsub("\n", "") == '' then - icon = icon .. "-off" - bluetooth_state = "off" - bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n") - else - icon = icon .. "-on" - bluetooth_state = "on" - awful.spawn.easy_async_with_shell( - './.config/awesome/src/scripts/bt.sh', - function(stdout2) - if stdout2 == nil or stdout2:gsub("\n", "") == "" then - bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently not connected") - else - connected_device = stdout2:gsub("%(", ""):gsub("%)", "") - bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently connected to:\n" .. connected_device) - end - end - ) - end - bluetooth_widget.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Grey900"])) - end, - bluetooth_widget - ) - - -- Signals - Hover_signal(bluetooth_widget, color["Blue200"]) - - bluetooth_widget:connect_signal( - "button::press", - function() - awful.spawn.easy_async_with_shell( - "rfkill list bluetooth", - function(stdout) - if stdout:gsub("\n", "") ~= '' then - if bluetooth_state == "off" then - awful.spawn.easy_async_with_shell( - [[ - rfkill unblock bluetooth - sleep 1 - bluetoothctl power on - ]], - function() - naughty.notify({ - title = "System Notification", - app_name = "Bluetooth", - message = "Bluetooth activated" - }) - end - ) - else - awful.spawn.easy_async_with_shell( - [[ - bluetoothctl power off - rfkill block bluetooth - ]], - function() - naughty.notify({ - title = "System Notification", - app_name = "Bluetooth", - message = "Bluetooth deactivated" - }) - end - ) - end - end - end - ) + awful.widget.watch( + "rfkill list bluetooth", + 5, + function(_, stdout) + local icon = icondir .. "bluetooth" + if stdout:match('Soft blocked: yes') or stdout:gsub("\n", "") == '' then + icon = icon .. "-off" + bluetooth_state = "off" + bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n") + else + icon = icon .. "-on" + bluetooth_state = "on" + awful.spawn.easy_async_with_shell( + './.config/awesome/src/scripts/bt.sh', + function(stdout2) + if stdout2 == nil or stdout2:gsub("\n", "") == "" then + bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently not connected") + else + connected_device = stdout2:gsub("%(", ""):gsub("%)", "") + bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently connected to:\n" .. connected_device) + end end - ) + ) + end + bluetooth_widget.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Grey900"])) + end, + bluetooth_widget + ) - return bluetooth_widget + -- Signals + Hover_signal(bluetooth_widget, color["Blue200"]) + + bluetooth_widget:connect_signal( + "button::press", + function() + awful.spawn.easy_async_with_shell( + "rfkill list bluetooth", + function(stdout) + if stdout:gsub("\n", "") ~= '' then + if bluetooth_state == "off" then + awful.spawn.easy_async_with_shell( + [[ + rfkill unblock bluetooth + sleep 1 + bluetoothctl power on + ]], + function() + naughty.notification { + title = "System Notification", + app_name = "Bluetooth", + message = "Bluetooth activated" + } + end + ) + else + awful.spawn.easy_async_with_shell( + [[ + bluetoothctl power off + rfkill block bluetooth + ]], + function() + naughty.notification { + title = "System Notification", + app_name = "Bluetooth", + message = "Bluetooth deactivated" + } + end + ) + end + end + end + ) + end + ) + + return bluetooth_widget end diff --git a/awesome/src/widgets/clock.lua b/awesome/src/widgets/clock.lua index d6d173e..ec4505b 100644 --- a/awesome/src/widgets/clock.lua +++ b/awesome/src/widgets/clock.lua @@ -16,63 +16,63 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/clock/" -- Returns the clock widget return function() - local clock_widget = wibox.widget { + local clock_widget = wibox.widget { + { + { { + { { - { - { - { - id = "icon", - image = gears.color.recolor_image(icondir .. "clock.svg", color["Grey900"]), - widget = wibox.widget.imagebox, - resize = false - }, - id = "icon_layout", - widget = wibox.container.place - }, - id = "icon_margin", - top = dpi(2), - widget = wibox.container.margin - }, - spacing = dpi(10), - { - id = "label", - align = "center", - valign = "center", - widget = wibox.widget.textbox - }, - id = "clock_layout", - layout = wibox.layout.fixed.horizontal + id = "icon", + image = gears.color.recolor_image(icondir .. "clock.svg", color["Grey900"]), + widget = wibox.widget.imagebox, + resize = false }, - id = "container", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin + id = "icon_layout", + widget = wibox.container.place + }, + id = "icon_margin", + top = dpi(2), + widget = wibox.container.margin }, - bg = color["Orange200"], - fg = color["Grey900"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } + spacing = dpi(10), + { + id = "label", + align = "center", + valign = "center", + widget = wibox.widget.textbox + }, + id = "clock_layout", + layout = wibox.layout.fixed.horizontal + }, + id = "container", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = color["Orange200"], + fg = color["Grey900"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } - local set_clock = function() - clock_widget.container.clock_layout.label:set_text(os.date("%H:%M")) + local set_clock = function() + clock_widget.container.clock_layout.label:set_text(os.date("%H:%M")) + end + + -- Updates the clock every 5 seconds, worst case you are 5 seconds behind + -- ¯\_(ツ)_/¯ + gears.timer { + timeout = 5, + autostart = true, + call_now = true, + callback = function() + set_clock() end + } - -- Updates the clock every 5 seconds, worst case you are 5 seconds behind - -- ¯\_(ツ)_/¯ - local clock_update = gears.timer { - timeout = 5, - autostart = true, - call_now = true, - callback = function() - set_clock() - end - } + Hover_signal(clock_widget, color["Orange200"]) - Hover_signal(clock_widget, color["Orange200"]) - - return clock_widget + return clock_widget end diff --git a/awesome/src/widgets/cpu_info.lua b/awesome/src/widgets/cpu_info.lua index 266f784..6697cea 100644 --- a/awesome/src/widgets/cpu_info.lua +++ b/awesome/src/widgets/cpu_info.lua @@ -7,7 +7,6 @@ local awful = require("awful") local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") -local naughty = require("naughty") local watch = awful.widget.watch local wibox = require("wibox") require("src.core.signals") diff --git a/awesome/src/widgets/date.lua b/awesome/src/widgets/date.lua index 2f142e6..e9b62ed 100644 --- a/awesome/src/widgets/date.lua +++ b/awesome/src/widgets/date.lua @@ -16,77 +16,77 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/date/" -- Returns the date widget return function() - local date_widget = wibox.widget { + local date_widget = wibox.widget { + { + { { + { { - { - { - { - id = "icon", - image = gears.color.recolor_image(icondir .. "calendar.svg", color["Grey900"]), - widget = wibox.widget.imagebox, - resize = false - }, - id = "icon_layout", - widget = wibox.container.place - }, - id = "icon_margin", - top = dpi(2), - widget = wibox.container.margin - }, - spacing = dpi(10), - { - id = "label", - align = "center", - valign = "center", - widget = wibox.widget.textbox - }, - id = "date_layout", - layout = wibox.layout.fixed.horizontal + id = "icon", + image = gears.color.recolor_image(icondir .. "calendar.svg", color["Grey900"]), + widget = wibox.widget.imagebox, + resize = false }, - id = "container", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin + id = "icon_layout", + widget = wibox.container.place + }, + id = "icon_margin", + top = dpi(2), + widget = wibox.container.margin }, - bg = color["Teal200"], - fg = color["Grey900"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } + spacing = dpi(10), + { + id = "label", + align = "center", + valign = "center", + widget = wibox.widget.textbox + }, + id = "date_layout", + layout = wibox.layout.fixed.horizontal + }, + id = "container", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = color["Teal200"], + fg = color["Grey900"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } - local set_date = function() - date_widget.container.date_layout.label:set_text(os.date("%a, %b %d")) + local set_date = function() + date_widget.container.date_layout.label:set_text(os.date("%a, %b %d")) + end + + -- Updates the date every minute, dont blame me if you miss silvester + gears.timer { + timeout = 60, + autostart = true, + call_now = true, + callback = function() + set_date() end + } - -- Updates the date every minute, dont blame me if you miss silvester - local date_updater = gears.timer { - timeout = 60, - autostart = true, - call_now = true, - callback = function() - set_date() - end - } + -- Signals + Hover_signal(date_widget, color["Teal200"]) - -- Signals - Hover_signal(date_widget, color["Teal200"]) + date_widget:connect_signal( + "mouse::enter", + function() + awesome.emit_signal("widget::calendar_osd:stop", true) + end + ) - date_widget:connect_signal( - "mouse::enter", - function() - awesome.emit_signal("widget::calendar_osd:stop", true) - end - ) + date_widget:connect_signal( + "mouse::leave", + function() + awesome.emit_signal("widget::calendar_osd:rerun", true) + end + ) - date_widget:connect_signal( - "mouse::leave", - function() - awesome.emit_signal("widget::calendar_osd:rerun", true) - end - ) - - return date_widget + return date_widget end diff --git a/awesome/src/widgets/gpu_info.lua b/awesome/src/widgets/gpu_info.lua index 7000494..a06a9cf 100644 --- a/awesome/src/widgets/gpu_info.lua +++ b/awesome/src/widgets/gpu_info.lua @@ -7,7 +7,6 @@ local awful = require("awful") local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") -local naughty = require("naughty") local watch = awful.widget.watch local wibox = require("wibox") require("src.core.signals") diff --git a/awesome/src/widgets/kblayout.lua b/awesome/src/widgets/kblayout.lua index b6d2378..0d559e2 100644 --- a/awesome/src/widgets/kblayout.lua +++ b/awesome/src/widgets/kblayout.lua @@ -14,326 +14,380 @@ require("src.core.signals") local icondir = awful.util.getdir("config") .. "src/assets/icons/kblayout/" return function(s) - local kblayout_widget = wibox.widget { + local kblayout_widget = wibox.widget { + { + { { + { { - { - { - { - id = "icon", - widget = wibox.widget.imagebox, - resize = false, - image = gears.color.recolor_image(icondir .. "keyboard.svg", color["Grey900"]) - }, - id = "icon_layout", - widget = wibox.container.place - }, - top = dpi(2), - widget = wibox.container.margin, - id = "icon_margin" - }, - spacing = dpi(10), - { - id = "label", - align = "center", - valign = "center", - widget = wibox.widget.textbox - }, - id = "kblayout_layout", - layout = wibox.layout.fixed.horizontal + id = "icon", + widget = wibox.widget.imagebox, + resize = false, + image = gears.color.recolor_image(icondir .. "keyboard.svg", color["Grey900"]) }, - id = "container", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin + id = "icon_layout", + widget = wibox.container.place + }, + top = dpi(2), + widget = wibox.container.margin, + id = "icon_margin" }, - bg = color["Green200"], - fg = color["Grey900"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background + spacing = dpi(10), + { + id = "label", + align = "center", + valign = "center", + widget = wibox.widget.textbox + }, + id = "kblayout_layout", + layout = wibox.layout.fixed.horizontal + }, + id = "container", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = color["Green200"], + fg = color["Grey900"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } + + local function get_kblayout() + awful.spawn.easy_async_with_shell( + [[ setxkbmap -query | grep layout | awk '{print $2}' ]], + function(stdout) + local layout = stdout:gsub("\n", "") + kblayout_widget.container.kblayout_layout.label.text = layout + awesome.emit_signal("update::background:kblayout") + end + ) + end + + local function create_kb_layout_item(keymap) + -- TODO: Add more, too lazy rn + local longname, shortname + + local xkeyboard_country_code = { + { "af", "أفغانيش(Afghanistan)", "AFG" }, -- Afghanistan + { "al", "shqip(Albania)", "ALB" }, -- Albania + { "am", "հայերեն(Armenia)", "ARM" }, -- Armenia + { "ara", "عربي(Arab)", "ARB" }, -- Arabic + { "at", "Österreichisch (Austria)", "AUT" }, -- Austria + { "az", "Azərbaycan(Azerbaijan)", "AZE" }, -- Azerbaijan + { "ba", "bosanski(Bosnia and Herzegovina)", "BIH" }, -- Bosnia and Herzegovina + { "bd", "", "BGD" }, -- Bangladesh + { "be", "", "BEL" }, -- Belgium + { "bg", "", "BGR" }, -- Bulgaria + { "br", "", "BRA" }, -- Brazil + { "bt", "", "BTN" }, -- Bhutan + { "bw", "", "BWA" }, -- Botswana + { "by", "", "BLR" }, -- Belarus + { "ca", "", "CAN" }, -- Canada + { "cd", "", "COD" }, -- Congo + { "ch", "", "CHE" }, -- Switzerland + { "cm", "", "CMR" }, -- Cameroon + { "cn", "", "CHN" }, -- China + { "cz", "", "CZE" }, -- Czechia + { "de", "Deutsch (Germany)", "GER" }, -- Germany + { "dk", "", "DNK" }, -- Denmark + { "ee", "", "EST" }, -- Estonia + { "es", "", "ESP" }, -- Spain + { "et", "", "ETH" }, -- Ethiopia + { "eu", "?", "?" }, -- EurKey + { "fi", "", "FIN" }, -- Finland + { "fo", "", "FRO" }, -- Faroe Islands + { "fr", "", "FRA" }, -- France + { "gb", "English (Bri'ish)", "ENG" }, -- United Kingdom + { "ge", "", "GEO" }, -- Georgia + { "gh", "", "GHA" }, -- Ghana + { "gn", "", "GIN" }, -- Guinea + { "gr", "", "GRC" }, -- Greece + { "hr", "", "HRV" }, -- Croatia + { "hu", "", "HUN" }, -- Hungary + { "ie", "", "IRL" }, -- Ireland + { "il", "", "ISR" }, -- Israel + { "in", "", "IND" }, -- India + { "iq", "", "IRQ" }, -- Iraq + { "ir", "", "IRN" }, -- Iran + { "is", "", "ISL" }, -- Iceland + { "it", "", "ITA" }, -- Italy + { "jp", "", "JPN" }, -- Japan + { "ke", "", "KEN" }, -- Kenya + { "kg", "", "KGZ" }, -- Kyrgyzstan + { "kh", "", "KHM" }, -- Cambodia + { "kr", "", "KOR" }, -- Korea + { "kz", "", "KAZ" }, -- Kazakhstan + { "la", "", "LAO" }, -- Laos + { "latam", "?", "?" }, -- Latin America + { "latin", "?", "?" }, -- Latin + { "lk", "", "LKA" }, -- Sri Lanka + { "lt", "", "LTU" }, -- Lithuania + { "lv", "", "LVA" }, -- Latvia + { "ma", "", "MAR" }, -- Morocco + { "mao", "?", "?" }, -- Maori + { "me", "", "MNE" }, -- Montenegro + { "mk", "", "MKD" }, -- Macedonia + { "ml", "", "MLI" }, -- Mali + { "mm", "", "MMR" }, -- Myanmar + { "mn", "", "MNG" }, -- Mongolia + { "mt", "", "MLT" }, -- Malta + { "mv", "", "MDV" }, -- Maldives + { "ng", "", "NGA" }, -- Nigeria + { "nl", "", "NLD" }, -- Netherlands + { "no", "", "NOR" }, -- Norway + { "np", "", "NRL" }, -- Nepal + { "ph", "", "PHL" }, -- Philippines + { "pk", "", "PAK" }, -- Pakistan + { "pl", "", "POL" }, -- Poland + { "pt", "", "PRT" }, -- Portugal + { "ro", "", "ROU" }, -- Romania + { "rs", "", "SRB" }, -- Serbia + { "ru", "Русский (Russia)", "RUS" }, -- Russia + { "se", "", "SWE" }, -- Sweden + { "si", "", "SVN" }, -- Slovenia + { "sk", "", "SVK" }, -- Slovakia + { "sn", "", "SEN" }, -- Senegal + { "sy", "", "SYR" }, -- Syria + { "th", "", "THA" }, -- Thailand + { "tj", "", "TJK" }, -- Tajikistan + { "tm", "", "TKM" }, -- Turkmenistan + { "tr", "", "TUR" }, -- Turkey + { "tw", "", "TWN" }, -- Taiwan + { "tz", "", "TZA" }, -- Tanzania + { "ua", "", "UKR" }, -- Ukraine + { "us", "English (United States)", "USA" }, -- USA + { "uz", "", "UZB" }, -- Uzbekistan + { "vn", "", "VNM" }, -- Vietnam + { "za", "", "ZAF" } -- South Africa } - local layout = ""; - local get_kblayout = function() - awful.spawn.easy_async_with_shell( - [[ setxkbmap -query | grep layout | awk '{print $2}' ]], - function(stdout) - layout = stdout:gsub("\n", "") - kblayout_widget.container.kblayout_layout.label.text = layout - return layout - end - ) - return layout + for _, c in ipairs(xkeyboard_country_code) do + if c[1] == keymap then + longname = c[2] + shortname = c[3] + end end - - local function create_kb_layout_item(keymap) - -- TODO: Add more, too lazy rn - local longname, shortname - - local xkeyboard_country_code = { - { "ad", "", "AND" }, -- Andorra - { "af", "", "AFG" }, -- Afghanistan - { "al", "", "ALB" }, -- Albania - { "am", "", "ARM" }, -- Armenia - { "ara", "", "ARB" }, -- Arabic - { "at", "", "AUT" }, -- Austria - { "az", "", "AZE" }, -- Azerbaijan - { "ba", "", "BIH" }, -- Bosnia and Herzegovina - { "bd", "", "BGD" }, -- Bangladesh - { "be", "", "BEL" }, -- Belgium - { "bg", "", "BGR" }, -- Bulgaria - { "br", "", "BRA" }, -- Brazil - { "bt", "", "BTN" }, -- Bhutan - { "bw", "", "BWA" }, -- Botswana - { "by", "", "BLR" }, -- Belarus - { "ca", "", "CAN" }, -- Canada - { "cd", "", "COD" }, -- Congo - { "ch", "", "CHE" }, -- Switzerland - { "cm", "", "CMR" }, -- Cameroon - { "cn", "", "CHN" }, -- China - { "cz", "", "CZE" }, -- Czechia - { "de", "Deutsch (Germany)", "GER" }, -- Germany - { "dk", "", "DNK" }, -- Denmark - { "ee", "", "EST" }, -- Estonia - { "es", "", "ESP" }, -- Spain - { "et", "", "ETH" }, -- Ethiopia - { "eu", "?", "?" }, -- EurKey - { "fi", "", "FIN" }, -- Finland - { "fo", "", "FRO" }, -- Faroe Islands - { "fr", "", "FRA" }, -- France - { "gb", "English (Bri'ish)", "ENG" }, -- United Kingdom - { "ge", "", "GEO" }, -- Georgia - { "gh", "", "GHA" }, -- Ghana - { "gn", "", "GIN" }, -- Guinea - { "gr", "", "GRC" }, -- Greece - { "hr", "", "HRV" }, -- Croatia - { "hu", "", "HUN" }, -- Hungary - { "ie", "", "IRL" }, -- Ireland - { "il", "", "ISR" }, -- Israel - { "in", "", "IND" }, -- India - { "iq", "", "IRQ" }, -- Iraq - { "ir", "", "IRN" }, -- Iran - { "is", "", "ISL" }, -- Iceland - { "it", "", "ITA" }, -- Italy - { "jp", "", "JPN" }, -- Japan - { "ke", "", "KEN" }, -- Kenya - { "kg", "", "KGZ" }, -- Kyrgyzstan - { "kh", "", "KHM" }, -- Cambodia - { "kr", "", "KOR" }, -- Korea - { "kz", "", "KAZ" }, -- Kazakhstan - { "la", "", "LAO" }, -- Laos - { "latam", "?", "?" }, -- Latin America - { "latin", "?", "?" }, -- Latin - { "lk", "", "LKA" }, -- Sri Lanka - { "lt", "", "LTU" }, -- Lithuania - { "lv", "", "LVA" }, -- Latvia - { "ma", "", "MAR" }, -- Morocco - { "mao", "?", "?" }, -- Maori - { "me", "", "MNE" }, -- Montenegro - { "mk", "", "MKD" }, -- Macedonia - { "ml", "", "MLI" }, -- Mali - { "mm", "", "MMR" }, -- Myanmar - { "mn", "", "MNG" }, -- Mongolia - { "mt", "", "MLT" }, -- Malta - { "mv", "", "MDV" }, -- Maldives - { "ng", "", "NGA" }, -- Nigeria - { "nl", "", "NLD" }, -- Netherlands - { "no", "", "NOR" }, -- Norway - { "np", "", "NRL" }, -- Nepal - { "ph", "", "PHL" }, -- Philippines - { "pk", "", "PAK" }, -- Pakistan - { "pl", "", "POL" }, -- Poland - { "pt", "", "PRT" }, -- Portugal - { "ro", "", "ROU" }, -- Romania - { "rs", "", "SRB" }, -- Serbia - { "ru", "Русски (Russia)", "RUS" }, -- Russia - { "se", "", "SWE" }, -- Sweden - { "si", "", "SVN" }, -- Slovenia - { "sk", "", "SVK" }, -- Slovakia - { "sn", "", "SEN" }, -- Senegal - { "sy", "", "SYR" }, -- Syria - { "th", "", "THA" }, -- Thailand - { "tj", "", "TJK" }, -- Tajikistan - { "tm", "", "TKM" }, -- Turkmenistan - { "tr", "", "TUR" }, -- Turkey - { "tw", "", "TWN" }, -- Taiwan - { "tz", "", "TZA" }, -- Tanzania - { "ua", "", "UKR" }, -- Ukraine - { "us", "English (United States)", "USA" }, -- USA - { "uz", "", "UZB" }, -- Uzbekistan - { "vn", "", "VNM" }, -- Vietnam - { "za", "", "ZAF" } -- South Africa - } - - for i, c in ipairs(xkeyboard_country_code) do - if c[1] == keymap then - longname = c[2] - shortname = c[3] - end - end - - local kb_layout_item = wibox.widget { + local kb_layout_item = wibox.widget { + { + { + -- Short name e.g. GER, ENG, RUS + { { - { - { - -- Short name e.g. GER, ENG, RUS - { - { - text = shortname, - widget = wibox.widget.textbox, - font = user_vars.font.extrabold, - id = "kbmapname" - }, - widget = wibox.container.margin, - id = "margin2" - }, - nil, - { - { - text = longname, - widget = wibox.widget.textbox, - font = user_vars.font.bold, - - }, - widget = wibox.container.margin - }, - spacing = dpi(15), - layout = wibox.layout.fixed.horizontal, - id = "container" - }, - margins = dpi(10), - widget = wibox.container.margin, - id = "margin" - }, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 10) - end, - bg = color["Grey800"], - fg = color["White"], - widget = wibox.container.background, - id = "background" + text = shortname, + widget = wibox.widget.textbox, + font = user_vars.font.extrabold, + id = "shortname" }, - margins = dpi(5), - widget = wibox.container.margin - } - Hover_signal(kb_layout_item.background, color["White"], color["Grey900"]) - kb_layout_item:connect_signal( - "button::press", - function() - awful.spawn.easy_async_with_shell( - "setxkbmap " .. keymap, - function(stdout) - awesome.emit_signal("kblayout::hide:kbmenu") - get_kblayout() - end - ) - end - ) - return kb_layout_item - end - - local function get_kblist() - local kb_layout_items = { - layout = wibox.layout.fixed.vertical - } - for i, keymap in pairs(user_vars.kblayout) do - kb_layout_items[i] = create_kb_layout_item(keymap) - end - return kb_layout_items - end - - local kb_menu_widget = awful.popup { - screen = s, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background, - bg = color["Grey900"], - fg = color["White"], - width = dpi(100), - max_height = dpi(600), - visible = false, - ontop = true, - placement = function(c) awful.placement.align(c, { position = "top_right", margins = { right = dpi(255), top = dpi(60) } }) end + fg = color["Red200"], + widget = wibox.container.background, + id = "background2" + }, + { + { + text = longname, + widget = wibox.widget.textbox, + font = user_vars.font.bold, + id = "longname", + }, + fg = color["Purple200"], + widget = wibox.container.background, + id = "background1" + }, + spacing = dpi(15), + layout = wibox.layout.fixed.horizontal, + id = "container" + }, + margins = dpi(10), + widget = wibox.container.margin, + id = "margin" + }, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 8) + end, + bg = color["Grey800"], + fg = color["White"], + widget = wibox.container.background, + id = "background", + keymap = keymap } - kb_menu_widget:setup( - get_kblist() - ) - - local function toggle_kb_layout() - awful.spawn.easy_async_with_shell( - "setxkbmap -query | grep layout: | awk '{print $2}'", - function(stdout) - for j, n in ipairs(user_vars.kblayout) do - if stdout:match(n) then - if j == #user_vars.kblayout then - awful.spawn.easy_async_with_shell( - "setxkbmap " .. user_vars.kblayout[1], - function() - get_kblayout() - end - ) - else - awful.spawn.easy_async_with_shell( - "setxkbmap " .. user_vars.kblayout[j + 1], - function() - get_kblayout() - end - ) - end - end - end - end - ) + -- TODO: Hover effects, this is more pain than I'm willing to take for now + awesome.connect_signal( + "update::background:kblayout", + function() + awful.spawn.easy_async_with_shell( + [[ setxkbmap -query | grep layout | awk '{print $2}' ]], + function(stdout) + local layout = stdout:gsub("\n", "") + if kb_layout_item.keymap == layout then + kb_layout_item.bg = color["DeepPurple200"] + kb_layout_item:get_children_by_id("background2")[1].fg = color["Grey900"] + kb_layout_item:get_children_by_id("background1")[1].fg = color["Grey900"] + else + kb_layout_item.bg = color["Grey800"] + kb_layout_item:get_children_by_id("background2")[1].fg = color["Red200"] + kb_layout_item:get_children_by_id("background1")[1].fg = color["Purple200"] + end + end + ) end - - awesome.connect_signal( - "kblayout::toggle", - function() - toggle_kb_layout() - end - ) - - --kb_menu_widget:move_next_to(mouse.current_widget_geometry) - -- Signals - Hover_signal(kblayout_widget, color["Green200"]) - - local kblayout_keygrabber = awful.keygrabber { - autostart = false, - stop_event = 'release', - keypressed_callback = function(self, mod, key, command) - if key == 'Escape' then - awesome.emit_signal("kblayout::hide:kbmenu") - end - end - } - - kblayout_widget:connect_signal( - "button::press", - function() - if kb_menu_widget.visible then - kb_menu_widget.visible = false - kblayout_keygrabber:stop() - else - kb_menu_widget.visible = true - kblayout_keygrabber:start() - end - end - ) - - awesome.connect_signal( - "kblayout::hide:kbmenu", - function() - kb_menu_widget.visible = false - kblayout_keygrabber:stop() - end ) get_kblayout() + + kb_layout_item:connect_signal( + "button::press", + function() + awful.spawn.easy_async_with_shell( + "setxkbmap " .. keymap, + function() + awesome.emit_signal("kblayout::hide:kbmenu") + mousegrabber.stop() + get_kblayout() + end + ) + end + ) + return kb_layout_item + end + + local function get_kblist() + local kb_layout_items = { + layout = wibox.layout.fixed.vertical, + spacing = dpi(10) + } + for i, keymap in pairs(user_vars.kblayout) do + kb_layout_items[i] = create_kb_layout_item(keymap) + end + local cont = { + { + kb_layout_items, + margins = dpi(10), + widget = wibox.container.margin + }, + layout = wibox.layout.fixed.vertical, + } + return cont + end + + local kb_menu_widget = awful.popup { + screen = s, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 12) + end, + widget = wibox.container.background, + bg = color["Grey900"], + fg = color["White"], + border_width = dpi(4), + border_color = color["Grey800"], + width = dpi(100), + max_height = dpi(600), + visible = false, + ontop = true, + placement = function(c) awful.placement.align(c, { position = "top_right", margins = { right = dpi(255), top = dpi(60) } }) end + } + + kb_menu_widget:connect_signal( + "mouse::leave", + function() + mousegrabber.run( + function() + kblayout_widget.bg = color["Green200"] + if mouse.is_left_mouse_button_pressed then + awesome.emit_signal("kblayout::hide:kbmenu") + mousegrabber.stop() + end + return true + end, + "arrow" + ) + end + ) + + kb_menu_widget:connect_signal( + "mouse::enter", + function() + mousegrabber.stop() + end + ) + + kb_menu_widget:setup( + get_kblist() + ) + + local function toggle_kb_layout() + awful.spawn.easy_async_with_shell( + "setxkbmap -query | grep layout: | awk '{print $2}'", + function(stdout) + for j, n in ipairs(user_vars.kblayout) do + if stdout:match(n) then + if j == #user_vars.kblayout then + awful.spawn.easy_async_with_shell( + "setxkbmap " .. user_vars.kblayout[1], + function() + get_kblayout() + end + ) + else + awful.spawn.easy_async_with_shell( + "setxkbmap " .. user_vars.kblayout[j + 1], + function() + get_kblayout() + end + ) + end + end + end + end + ) + end + + awesome.connect_signal( + "kblayout::toggle", + function() + toggle_kb_layout() + end + ) + + -- Signals + Hover_signal(kblayout_widget, color["Green200"]) + + local kblayout_keygrabber = awful.keygrabber { + autostart = false, + stop_event = 'release', + keypressed_callback = function(self, mod, key, command) + awesome.emit_signal("kblayout::hide:kbmenu") + mousegrabber.stop() + end + } + + kblayout_widget:connect_signal( + "button::press", + function() + mousegrabber.stop() + if kb_menu_widget.visible then + kb_menu_widget.visible = false + kblayout_keygrabber:stop() + else + kb_menu_widget.visible = true + kblayout_keygrabber:start() + end + end + ) + + awesome.connect_signal( + "kblayout::hide:kbmenu", + function() kb_menu_widget.visible = false - return kblayout_widget + kblayout_keygrabber:stop() + end + ) + + get_kblayout() + kb_menu_widget.visible = false + return kblayout_widget end diff --git a/awesome/src/widgets/layout_list.lua b/awesome/src/widgets/layout_list.lua index e007c87..a1e1d2e 100644 --- a/awesome/src/widgets/layout_list.lua +++ b/awesome/src/widgets/layout_list.lua @@ -12,35 +12,35 @@ require("src.core.signals") -- Returns the layoutbox widget return function() - local layout = wibox.widget { - { - { - awful.widget.layoutbox(), - id = "icon_layout", - widget = wibox.container.place - }, - id = "icon_margin", - left = dpi(5), - right = dpi(5), - forced_width = dpi(40), - widget = wibox.container.margin - }, - bg = color["LightBlue200"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } + local layout = wibox.widget { + { + { + awful.widget.layoutbox(), + id = "icon_layout", + widget = wibox.container.place + }, + id = "icon_margin", + left = dpi(5), + right = dpi(5), + forced_width = dpi(40), + widget = wibox.container.margin + }, + bg = color["LightBlue200"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } - -- Signals - Hover_signal(layout, color["LightBlue200"]) + -- Signals + Hover_signal(layout, color["LightBlue200"]) - layout:connect_signal( - "button::press", - function() - awful.layout.inc(-1) - end - ) + layout:connect_signal( + "button::press", + function() + awful.layout.inc(-1) + end + ) - return layout + return layout end diff --git a/awesome/src/widgets/network.lua b/awesome/src/widgets/network.lua index 27292a9..952ba03 100644 --- a/awesome/src/widgets/network.lua +++ b/awesome/src/widgets/network.lua @@ -16,68 +16,68 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/network/" -- Insert your interfaces here, get the from ip a local interfaces = { - wlan_interface = user_vars.network.wlan, - lan_interface = user_vars.network.ethernet + wlan_interface = user_vars.network.wlan, + lan_interface = user_vars.network.ethernet } local network_mode = nil -- Returns the network widget return function() - local startup = true - local reconnect_startup = true - local wifi_strength - local network_widget = wibox.widget { + local startup = true + local reconnect_startup = true + local wifi_strength + local network_widget = wibox.widget { + { + { { + { { - { - { - { - id = 'icon', - image = gears.color.recolor_image(icondir .. "no-internet" .. ".svg", color["Grey900"]), - widget = wibox.widget.imagebox, - resize = false - }, - id = "icon_layout", - widget = wibox.container.place - }, - id = "icon_margin", - top = dpi(2), - widget = wibox.container.margin - }, - spacing = dpi(10), - { - id = "label", - visible = false, - valign = "center", - align = "center", - widget = wibox.widget.textbox - }, - id = "network_layout", - layout = wibox.layout.fixed.horizontal + id = 'icon', + image = gears.color.recolor_image(icondir .. "no-internet" .. ".svg", color["Grey900"]), + widget = wibox.widget.imagebox, + resize = false }, - id = "container", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin + id = "icon_layout", + widget = wibox.container.place + }, + id = "icon_margin", + top = dpi(2), + widget = wibox.container.margin }, - bg = color["Red200"], - fg = color["Grey900"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } + spacing = dpi(10), + { + id = "label", + visible = false, + valign = "center", + align = "center", + widget = wibox.widget.textbox + }, + id = "network_layout", + layout = wibox.layout.fixed.horizontal + }, + id = "container", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = color["Red200"], + fg = color["Grey900"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } - local network_tooltip = awful.tooltip { - text = "Loading", - objects = { network_widget }, - mode = "inside", - preferred_alignments = "middle", - margins = dpi(10) - } + local network_tooltip = awful.tooltip { + text = "Loading", + objects = { network_widget }, + mode = "inside", + preferred_alignments = "middle", + margins = dpi(10) + } - local check_for_internet = [=[ + local check_for_internet = [=[ status_ping=0 packets="$(ping -q -w2 -c2 1.1.1.1 | grep -o "100% packet loss")" if [ ! -z "${packets}" ]; @@ -92,181 +92,181 @@ return function() fi ]=] - local update_startup = function() - if startup then - startup = false - end + local update_startup = function() + if startup then + startup = false + end + end + + local update_reconnect_startup = function(status) + reconnect_startup = status + end + + local update_tooltip = function(message) + network_tooltip:set_markup(message) + end + + local network_notify = function(message, title, app_name, icon) + naughty.notification { + text = message, + title = title, + app_name = app_name, + icon = gears.color.recolor_image(icon, color["White"]), + timeout = 3 + } + end + + local update_wireless = function() + network_mode = "wireless" + + local notify_connected = function(essid) + local message = "You are now connected to " .. essid + local title = "Connection successfull" + local app_name = "System Notification" + local icon = icondir .. "wifi-strength-4.svg" + network_notify(message, title, app_name, icon) end - local update_reconnect_startup = function(status) - reconnect_startup = status + local update_wireless_data = function(healthy) + awful.spawn.easy_async_with_shell( + [[ iw dev ]] .. interfaces.wlan_interface .. [[ link ]], + function(stdout) + local essid = stdout:match("SSID: (.-)\n") or "N/A" + local bitrate = stdout:match("tx bitrate: (.+/s)") or "N/A" + local message = "Connected to " .. essid .. "\nSignal strength " .. tostring(wifi_strength) .. "%\n" .. "Bit rate " .. tostring(bitrate) .. "" + + if healthy then + update_tooltip(message) + else + update_tooltip("You are connected but have no internet" .. message) + end + + if reconnect_startup or startup then + notify_connected(essid) + update_reconnect_startup(false) + end + end + ) end - local update_tooltip = function(message) - network_tooltip:set_markup(message) - end - - local network_notify = function(message, title, app_name, icon) - naughty.notify({ - text = message, - title = title, - app_name = app_name, - icon = gears.color.recolor_image(icon, color["White"]), - timeout = 3 - }) - end - - local update_wireless = function() - network_mode = "wireless" - - local notify_connected = function(essid) - local message = "You are now connected to " .. essid - local title = "Connection successfull" - local app_name = "System Notification" - local icon = icondir .. "wifi-strength-4.svg" - network_notify(message, title, app_name, icon) + local update_wireless_icon = function(strength) + awful.spawn.easy_async_with_shell( + check_for_internet, + function(stdout) + local icon = "wifi-strength" + if not stdout:match("Connected but no internet") then + if startup or reconnect_startup then + awesome.emit_signal("system::network_connected") + end + icon = icon .. '-' .. tostring(strength) + update_wireless_data(true) + else + icon = icon .. "-" .. tostring(strength) + update_wireless_data(false) end - - local update_wireless_data = function(healthy) - awful.spawn.easy_async_with_shell( - [[ iw dev ]] .. interfaces.wlan_interface .. [[ link ]], - function(stdout) - local essid = stdout:match("SSID: (.-)\n") or "N/A" - local bitrate = stdout:match("tx bitrate: (.+/s)") or "N/A" - local message = "Connected to " .. essid .. "\nSignal strength " .. tostring(wifi_strength) .. "%\n" .. "Bit rate " .. tostring(bitrate) .. "" - - if healthy then - update_tooltip(message) - else - update_tooltip("You are connected but have no internet" .. message) - end - - if reconnect_startup or startup then - notify_connected(essid) - update_reconnect_startup(false) - end - end - ) - end - - local update_wireless_icon = function(strength) - awful.spawn.easy_async_with_shell( - check_for_internet, - function(stdout) - local icon = "wifi-strength" - if not stdout:match("Connected but no internet") then - if startup or reconnect_startup then - awesome.emit_signal("system::network_connected") - end - icon = icon .. '-' .. tostring(strength) - update_wireless_data(true) - else - icon = icon .. "-" .. tostring(strength) - update_wireless_data(false) - end - network_widget.container.network_layout.spacing = dpi(8) - network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color["Grey900"])) - end - ) - end - - local update_wireless_strength = function() - awful.spawn.easy_async_with_shell( - [[ awk 'NR==3 {printf "%3.0f", ($3/70)*100}' /proc/net/wireless ]], - function(stdout) - if not tonumber(stdout) then - return - end - wifi_strength = tonumber(stdout) - network_widget.container.network_layout.spacing = dpi(8) - network_widget.container.network_layout.label.visible = true - network_widget.container.network_layout.label:set_text(tostring(wifi_strength .. "%")) - local wifi_strength_rounded = math.floor(wifi_strength / 25 + 0.5) - update_wireless_icon(wifi_strength_rounded) - end - ) - end - - update_wireless_strength() - update_startup() - end - - local update_wired = function() - network_mode = "wired" - - local notify_connected = function() - local message = "You are now connected to " .. interfaces.lan_interface - local title = "Connection successfull" - local app_name = "System Notification" - local icon = icondir .. "ethernet.svg" - network_notify(message, title, app_name, icon) - end - - awful.spawn.easy_async_with_shell( - check_for_internet, - function(stdout) - local icon = "ethernet" - - if stdout:match("Connected but no internet") then - icon = "no-internet" - update_tooltip( - "No internet" - ) - else - update_tooltip("You are connected to:\nEthernet Interface " .. interfaces.lan_interface .. "") - if startup or reconnect_startup then - awesome.emit_signal("system::network_connected") - notify_connected() - update_startup() - end - update_reconnect_startup(false) - end - network_widget.container.network_layout.label.visible = false - network_widget.container.network_layout.spacing = dpi(0) - network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(icondir .. icon .. ".svg") - end - ) - - end - - local update_disconnected = function() - local notify_wireless_disconnected = function(essid) - local message = "WiFi has been disconnected" - local title = "Connection lost" - local app_name = "System Notification" - local icon = icondir .. "wifi-strength-off-outline.svg" - network_notify(message, title, app_name, icon) - end - local notify_wired_disconnected = function(essid) - local message = "Ethernet has been unplugged" - local title = "Connection lost" - local app_name = "System Notification" - local icon = icondir .. "no-internet.svg" - network_notify(message, title, app_name, icon) - end - local icon = "wifi-strength-off-outline" - if network_mode == "wireless" then - icon = "wifi-strength-off-outline" - if not reconnect_startup then - update_reconnect_startup(true) - notify_wireless_disconnected() - end - elseif network_mode == "wired" then - icon = "no-internet" - if not reconnect_startup then - update_reconnect_startup(true) - notify_wired_disconnected() - end - end - network_widget.container.network_layout.label.visible = false - update_tooltip("Network unreachable") - network_widget.container.network_layout.spacing = dpi(0) + network_widget.container.network_layout.spacing = dpi(8) network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color["Grey900"])) + end + ) end - local check_network_mode = function() - awful.spawn.easy_async_with_shell( - [=[ + local update_wireless_strength = function() + awful.spawn.easy_async_with_shell( + [[ awk 'NR==3 {printf "%3.0f", ($3/70)*100}' /proc/net/wireless ]], + function(stdout) + if not tonumber(stdout) then + return + end + wifi_strength = tonumber(stdout) + network_widget.container.network_layout.spacing = dpi(8) + network_widget.container.network_layout.label.visible = true + network_widget.container.network_layout.label:set_text(tostring(wifi_strength .. "%")) + local wifi_strength_rounded = math.floor(wifi_strength / 25 + 0.5) + update_wireless_icon(wifi_strength_rounded) + end + ) + end + + update_wireless_strength() + update_startup() + end + + local update_wired = function() + network_mode = "wired" + + local notify_connected = function() + local message = "You are now connected to " .. interfaces.lan_interface + local title = "Connection successfull" + local app_name = "System Notification" + local icon = icondir .. "ethernet.svg" + network_notify(message, title, app_name, icon) + end + + awful.spawn.easy_async_with_shell( + check_for_internet, + function(stdout) + local icon = "ethernet" + + if stdout:match("Connected but no internet") then + icon = "no-internet" + update_tooltip( + "No internet" + ) + else + update_tooltip("You are connected to:\nEthernet Interface " .. interfaces.lan_interface .. "") + if startup or reconnect_startup then + awesome.emit_signal("system::network_connected") + notify_connected() + update_startup() + end + update_reconnect_startup(false) + end + network_widget.container.network_layout.label.visible = false + network_widget.container.network_layout.spacing = dpi(0) + network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(icondir .. icon .. ".svg") + end + ) + + end + + local update_disconnected = function() + local notify_wireless_disconnected = function(essid) + local message = "WiFi has been disconnected" + local title = "Connection lost" + local app_name = "System Notification" + local icon = icondir .. "wifi-strength-off-outline.svg" + network_notify(message, title, app_name, icon) + end + local notify_wired_disconnected = function(essid) + local message = "Ethernet has been unplugged" + local title = "Connection lost" + local app_name = "System Notification" + local icon = icondir .. "no-internet.svg" + network_notify(message, title, app_name, icon) + end + local icon = "wifi-strength-off-outline" + if network_mode == "wireless" then + icon = "wifi-strength-off-outline" + if not reconnect_startup then + update_reconnect_startup(true) + notify_wireless_disconnected() + end + elseif network_mode == "wired" then + icon = "no-internet" + if not reconnect_startup then + update_reconnect_startup(true) + notify_wired_disconnected() + end + end + network_widget.container.network_layout.label.visible = false + update_tooltip("Network unreachable") + network_widget.container.network_layout.spacing = dpi(0) + network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color["Grey900"])) + end + + local check_network_mode = function() + awful.spawn.easy_async_with_shell( + [=[ wireless="]=] .. tostring(interfaces.wlan_interface) .. [=[" wired="]=] .. tostring(interfaces.lan_interface) .. [=[" net="/sys/class/net/" @@ -301,37 +301,37 @@ return function() } print_network_mode ]=], - function(stdout) - local mode = stdout:gsub("%\n", "") - if stdout:match("No internet connected") then - update_disconnected() - elseif stdout:match("wireless") then - update_wireless() - elseif stdout:match("wired") then - update_wired() - end - end - ) + function(stdout) + local mode = stdout:gsub("%\n", "") + if stdout:match("No internet connected") then + update_disconnected() + elseif stdout:match("wireless") then + update_wireless() + elseif stdout:match("wired") then + update_wired() + end end - - local network_updater = gears.timer { - timeout = 5, - autostart = true, - call_now = true, - callback = function() - check_network_mode() - end - } - - -- Signals - Hover_signal(network_widget, color["Red200"]) - - network_widget:connect_signal( - "button::press", - function() - awful.spawn("gnome-control-center wlan") - end ) + end - return network_widget + gears.timer { + timeout = 5, + autostart = true, + call_now = true, + callback = function() + check_network_mode() + end + } + + -- Signals + Hover_signal(network_widget, color["Red200"]) + + network_widget:connect_signal( + "button::press", + function() + awful.spawn("gnome-control-center wlan") + end + ) + + return network_widget end diff --git a/awesome/src/widgets/power.lua b/awesome/src/widgets/power.lua index c4b380d..5e36982 100644 --- a/awesome/src/widgets/power.lua +++ b/awesome/src/widgets/power.lua @@ -15,49 +15,49 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/power/" return function() - local power_widget = wibox.widget { + local power_widget = wibox.widget { + { + { { + { { - { - { - { - id = "icon", - image = gears.color.recolor_image(icondir .. "power.svg", color["Grey900"]), - widget = wibox.widget.imagebox, - resize = false - }, - id = "icon_layout", - widget = wibox.container.place - }, - id = "icon_margin", - top = dpi(2), - widget = wibox.container.margin - }, - id = "power_layout", - layout = wibox.layout.fixed.horizontal + id = "icon", + image = gears.color.recolor_image(icondir .. "power.svg", color["Grey900"]), + widget = wibox.widget.imagebox, + resize = false }, - id = "container", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin + id = "icon_layout", + widget = wibox.container.place + }, + id = "icon_margin", + top = dpi(2), + widget = wibox.container.margin }, - bg = color["Red200"], - fg = color["Grey800"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } + id = "power_layout", + layout = wibox.layout.fixed.horizontal + }, + id = "container", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = color["Red200"], + fg = color["Grey800"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } - -- Signals - Hover_signal(power_widget, color["Red200"]) + -- Signals + Hover_signal(power_widget, color["Red200"]) - power_widget:connect_signal( - "button::release", - function() - awesome.emit_signal("module::powermenu:show") - end - ) + power_widget:connect_signal( + "button::release", + function() + awesome.emit_signal("module::powermenu:show") + end + ) - return power_widget + return power_widget end diff --git a/awesome/src/widgets/ram_info.lua b/awesome/src/widgets/ram_info.lua index bcd6ee9..74db52c 100644 --- a/awesome/src/widgets/ram_info.lua +++ b/awesome/src/widgets/ram_info.lua @@ -7,7 +7,6 @@ local awful = require("awful") local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") -local naughty = require("naughty") local watch = awful.widget.watch local wibox = require("wibox") require("src.core.signals") diff --git a/awesome/src/widgets/systray.lua b/awesome/src/widgets/systray.lua index a26953e..c0a87c1 100644 --- a/awesome/src/widgets/systray.lua +++ b/awesome/src/widgets/systray.lua @@ -12,37 +12,37 @@ local wibox = require("wibox") require("src.core.signals") return function(s) - local systray = wibox.widget { - { - { - wibox.widget.systray(), - widget = wibox.container.margin, - id = 'st' - }, - strategy = "exact", - layout = wibox.container.constraint, - id = "container" - }, - widget = wibox.container.background, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - bg = color["BlueGrey800"] - } - -- Signals - Hover_signal(systray.container, color["Red200"]) + local systray = wibox.widget { + { + { + wibox.widget.systray(), + widget = wibox.container.margin, + id = 'st' + }, + strategy = "exact", + layout = wibox.container.constraint, + id = "container" + }, + widget = wibox.container.background, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + bg = color["BlueGrey800"] + } + -- Signals + Hover_signal(systray.container, color["Red200"]) - awesome.connect_signal("systray::update", function() - local num_entries = awesome.systray() + awesome.connect_signal("systray::update", function() + local num_entries = awesome.systray() - if num_entries == 0 then - systray.container.st:set_margins(0) - else - systray.container.st:set_margins(dpi(6)) - end - end) + if num_entries == 0 then + systray.container.st:set_margins(0) + else + systray.container.st:set_margins(dpi(6)) + end + end) - systray.container.st.widget:set_base_size(dpi(20)) + systray.container.st.widget:set_base_size(dpi(20)) - return systray + return systray end diff --git a/awesome/src/widgets/taglist.lua b/awesome/src/widgets/taglist.lua index 4e90f25..d6a44f5 100644 --- a/awesome/src/widgets/taglist.lua +++ b/awesome/src/widgets/taglist.lua @@ -6,235 +6,235 @@ local color = require("src.theme.colors") require("src.tools.icon_handler") local list_update = function(widget, buttons, label, data, objects) - widget:reset() + widget:reset() - for i, object in ipairs(objects) do + for i, object in ipairs(objects) do - local tag_icon = wibox.widget { - nil, - { - id = "icon", - resize = true, - widget = wibox.widget.imagebox - }, - nil, - layout = wibox.layout.align.horizontal - } + local tag_icon = wibox.widget { + nil, + { + id = "icon", + resize = true, + widget = wibox.widget.imagebox + }, + nil, + layout = wibox.layout.align.horizontal + } - local tag_icon_margin = wibox.widget { - tag_icon, - forced_width = dpi(33), - margins = dpi(3), - widget = wibox.container.margin - } + local tag_icon_margin = wibox.widget { + tag_icon, + forced_width = dpi(33), + margins = dpi(3), + widget = wibox.container.margin + } - local tag_label = wibox.widget { - text = "", - align = "center", - valign = "center", - visible = true, - font = user_vars.font.extrabold, - forced_width = dpi(25), - widget = wibox.widget.textbox - } + local tag_label = wibox.widget { + text = "", + align = "center", + valign = "center", + visible = true, + font = user_vars.font.extrabold, + forced_width = dpi(25), + widget = wibox.widget.textbox + } - local tag_label_margin = wibox.widget { - tag_label, - left = dpi(5), - right = dpi(5), - widget = wibox.container.margin - } + local tag_label_margin = wibox.widget { + tag_label, + left = dpi(5), + right = dpi(5), + widget = wibox.container.margin + } - local tag_widget = wibox.widget { + local tag_widget = wibox.widget { - id = "widget_margin", - { - id = "container", - tag_label_margin, - layout = wibox.layout.fixed.horizontal - }, + id = "widget_margin", + { + id = "container", + tag_label_margin, + layout = wibox.layout.fixed.horizontal + }, - fg = color["White"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + fg = color["White"], + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, 5) + end, + widget = wibox.container.background + } + + local function create_buttons(buttons, object) + if buttons then + local btns = {} + for _, b in ipairs(buttons) do + local btn = awful.button { + modifiers = b.modifiers, + button = b.button, + on_press = function() + b:emit_signal('press', object) end, - widget = wibox.container.background - } - - local function create_buttons(buttons, object) - if buttons then - local btns = {} - for _, b in ipairs(buttons) do - local btn = awful.button { - modifiers = b.modifiers, - button = b.button, - on_press = function() - b:emit_signal('press', object) - end, - on_release = function() - b:emit_signal('release', object) - end - } - btns[#btns + 1] = btn - end - return btns + on_release = function() + b:emit_signal('release', object) end + } + btns[#btns + 1] = btn end - - tag_widget:buttons(create_buttons(buttons, object)) - - local text, bg_color, bg_image, icon, args = label(object, tag_label) - tag_label:set_text(object.index) - if object.urgent == true then - tag_widget:set_bg(color["RedA200"]) - tag_widget:set_fg(color["Grey900"]) - elseif object == awful.screen.focused().selected_tag then - tag_widget:set_bg(color["White"]) - tag_widget:set_fg(color["Grey900"]) - else - tag_widget:set_bg("#3A475C") - end - - -- Set the icon for each client - for _, client in ipairs(object:clients()) do - tag_label_margin:set_right(0) - local icon = wibox.widget { - { - id = "icon_container", - { - id = "icon", - resize = true, - widget = wibox.widget.imagebox - }, - widget = wibox.container.place - }, - tag_icon_margin, - forced_width = dpi(33), - margins = dpi(6), - widget = wibox.container.margin - } - icon.icon_container.icon:set_image(Get_icon(user_vars.icon_theme, client)) - tag_widget.container:setup({ - icon, - strategy = "exact", - layout = wibox.container.constraint, - }) - end - - local old_wibox, old_cursor, old_bg - tag_widget:connect_signal( - "mouse::enter", - function() - old_bg = tag_widget.bg - if object == awful.screen.focused().selected_tag then - tag_widget.bg = '#dddddd' .. 'dd' - else - tag_widget.bg = '#3A475C' .. 'dd' - end - local w = mouse.current_wibox - if w then - old_cursor, old_wibox = w.cursor, w - w.cursor = "hand1" - end - end - ) - - tag_widget:connect_signal( - "button::press", - function() - if object == awful.screen.focused().selected_tag then - tag_widget.bg = '#bbbbbb' .. 'dd' - else - tag_widget.bg = '#3A475C' .. 'dd' - end - end - ) - - tag_widget:connect_signal( - "button::release", - function() - if object == awful.screen.focused().selected_tag then - tag_widget.bg = '#dddddd' .. 'dd' - else - tag_widget.bg = '#3A475C' .. 'dd' - end - end - ) - - tag_widget:connect_signal( - "mouse::leave", - function() - tag_widget.bg = old_bg - if old_wibox then - old_wibox.cursor = old_cursor - old_wibox = nil - end - end - ) - - widget:add(tag_widget) - widget:set_spacing(dpi(6)) + return btns + end end + + tag_widget:buttons(create_buttons(buttons, object)) + + local text, bg_color, bg_image, icon, args = label(object, tag_label) + tag_label:set_text(object.index) + if object.urgent == true then + tag_widget:set_bg(color["RedA200"]) + tag_widget:set_fg(color["Grey900"]) + elseif object == awful.screen.focused().selected_tag then + tag_widget:set_bg(color["White"]) + tag_widget:set_fg(color["Grey900"]) + else + tag_widget:set_bg("#3A475C") + end + + -- Set the icon for each client + for _, client in ipairs(object:clients()) do + tag_label_margin:set_right(0) + local icon = wibox.widget { + { + id = "icon_container", + { + id = "icon", + resize = true, + widget = wibox.widget.imagebox + }, + widget = wibox.container.place + }, + tag_icon_margin, + forced_width = dpi(33), + margins = dpi(6), + widget = wibox.container.margin + } + icon.icon_container.icon:set_image(Get_icon(user_vars.icon_theme, client)) + tag_widget.container:setup({ + icon, + strategy = "exact", + layout = wibox.container.constraint, + }) + end + + local old_wibox, old_cursor, old_bg + tag_widget:connect_signal( + "mouse::enter", + function() + old_bg = tag_widget.bg + if object == awful.screen.focused().selected_tag then + tag_widget.bg = '#dddddd' .. 'dd' + else + tag_widget.bg = '#3A475C' .. 'dd' + end + local w = mouse.current_wibox + if w then + old_cursor, old_wibox = w.cursor, w + w.cursor = "hand1" + end + end + ) + + tag_widget:connect_signal( + "button::press", + function() + if object == awful.screen.focused().selected_tag then + tag_widget.bg = '#bbbbbb' .. 'dd' + else + tag_widget.bg = '#3A475C' .. 'dd' + end + end + ) + + tag_widget:connect_signal( + "button::release", + function() + if object == awful.screen.focused().selected_tag then + tag_widget.bg = '#dddddd' .. 'dd' + else + tag_widget.bg = '#3A475C' .. 'dd' + end + end + ) + + tag_widget:connect_signal( + "mouse::leave", + function() + tag_widget.bg = old_bg + if old_wibox then + old_wibox.cursor = old_cursor + old_wibox = nil + end + end + ) + + widget:add(tag_widget) + widget:set_spacing(dpi(6)) + end end local tag_list = function(s) - return awful.widget.taglist( - s, - awful.widget.taglist.filter.noempty, - gears.table.join( - awful.button( - {}, - 1, - function(t) - t:view_only() - end - ), - awful.button( - { modkey }, - 1, - function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end - ), - awful.button( - {}, - 3, - function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end - ), - awful.button( - { modkey }, - 3, - function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end - ), - awful.button( - {}, - 4, - function(t) - awful.tag.viewnext(t.screen) - end - ), - awful.button( - {}, - 5, - function(t) - awful.tag.viewprev(t.screen) - end - ) - ), + return awful.widget.taglist( + s, + awful.widget.taglist.filter.noempty, + gears.table.join( + awful.button( {}, - list_update, - wibox.layout.fixed.horizontal() - ) + 1, + function(t) + t:view_only() + end + ), + awful.button( + { modkey }, + 1, + function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end + ), + awful.button( + {}, + 3, + function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end + ), + awful.button( + { modkey }, + 3, + function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end + ), + awful.button( + {}, + 4, + function(t) + awful.tag.viewnext(t.screen) + end + ), + awful.button( + {}, + 5, + function(t) + awful.tag.viewprev(t.screen) + end + ) + ), + {}, + list_update, + wibox.layout.fixed.horizontal() + ) end return tag_list diff --git a/awesome/src/widgets/tasklist.lua b/awesome/src/widgets/tasklist.lua index 671ee46..a36369b 100644 --- a/awesome/src/widgets/tasklist.lua +++ b/awesome/src/widgets/tasklist.lua @@ -6,9 +6,7 @@ local color = require('src.theme.colors') local list_update = function(widget, buttons, label, data, objects) widget:reset() - local count - for i, object in ipairs(objects) do - count = i + for _, object in ipairs(objects) do local task_widget = wibox.widget { { { @@ -56,7 +54,10 @@ local list_update = function(widget, buttons, label, data, objects) local task_tool_tip = awful.tooltip { objects = { task_widget }, mode = "inside", - align = "right", + preferred_alignments = "middle", + preferred_positions = "bottom", + margins = dpi(10), + gaps = 0, delay_show = 1 } @@ -115,51 +116,51 @@ local list_update = function(widget, buttons, label, data, objects) task_widget:connect_signal( "mouse::enter", function() - old_bg = task_widget.bg - if object == client.focus then - task_widget.bg = '#dddddddd' - else - task_widget.bg = '#3A475Cdd' - end - local w = mouse.current_wibox - if w then - old_cursor, old_wibox = w.cursor, w - w.cursor = "hand1" - end + old_bg = task_widget.bg + if object == client.focus then + task_widget.bg = '#dddddddd' + else + task_widget.bg = '#3A475Cdd' end + local w = mouse.current_wibox + if w then + old_cursor, old_wibox = w.cursor, w + w.cursor = "hand1" + end + end ) task_widget:connect_signal( "button::press", function() - if object == client.focus then - task_widget.bg = "#ffffffaa" - else - task_widget.bg = '#3A475Caa' - end + if object == client.focus then + task_widget.bg = "#ffffffaa" + else + task_widget.bg = '#3A475Caa' end + end ) task_widget:connect_signal( "button::release", function() - if object == client.focus then - task_widget.bg = "#ffffffdd" - else - task_widget.bg = '#3A475Cdd' - end + if object == client.focus then + task_widget.bg = "#ffffffdd" + else + task_widget.bg = '#3A475Cdd' end + end ) task_widget:connect_signal( "mouse::leave", function() - task_widget.bg = old_bg - if old_wibox then - old_wibox.cursor = old_cursor - old_wibox = nil - end + task_widget.bg = old_bg + if old_wibox then + old_wibox.cursor = old_cursor + old_wibox = nil end + end ) end return widget @@ -174,24 +175,24 @@ local tasklist = function(s) {}, 1, function(c) - if c == client.focus then - c.minimized = true - else - c.minimized = false - if not c:isvisible() and c.first_tag then - c.first_tag:view_only() - end - c:emit_signal('request::activate') - c:raise() + if c == client.focus then + c.minimized = true + else + c.minimized = false + if not c:isvisible() and c.first_tag then + c.first_tag:view_only() end + c:emit_signal('request::activate') + c:raise() end + end ), awful.button( {}, 3, function(c) - c:kill() - end + c:kill() + end ) ), {},