From 6749335defbee3de332cb0961ca33220396b8acd Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 12 Mar 2026 01:25:21 +0100 Subject: [PATCH] configuration de base avec awesomeWM minimal et modularise, polybar et rofi --- awesome/modules/keys.lua | 65 +++++++++++++++ awesome/modules/rules.lua | 16 ++++ awesome/modules/signals.lua | 13 +++ awesome/modules/tags.lua | 19 +++++ awesome/rc.lua | 20 +++++ polybar/launch.sh | 6 ++ polybar/main.ini | 130 +++++++++++++++++++++++++++++ polybar/scripts/powermenu.sh | 21 +++++ rofi/config.rasi | 155 +++++++++++++++++++++++++++++++++++ 9 files changed, 445 insertions(+) create mode 100644 awesome/modules/keys.lua create mode 100644 awesome/modules/rules.lua create mode 100644 awesome/modules/signals.lua create mode 100644 awesome/modules/tags.lua create mode 100644 awesome/rc.lua create mode 100755 polybar/launch.sh create mode 100644 polybar/main.ini create mode 100755 polybar/scripts/powermenu.sh create mode 100644 rofi/config.rasi diff --git a/awesome/modules/keys.lua b/awesome/modules/keys.lua new file mode 100644 index 0000000..b3c7d4c --- /dev/null +++ b/awesome/modules/keys.lua @@ -0,0 +1,65 @@ +local awful = require("awful") +local gears = require("gears") + +-- Raccourcis globaux +local global_keys = gears.table.join( + awful.key({ modkey }, "Return", function() awful.spawn(terminal) end, + { description = "ouvrir terminal", group = "launcher" }), + + awful.key({ modkey, "Control" }, "r", awesome.restart, + { description = "recharger awesome", group = "awesome" }), + + awful.key({ modkey, "Shift" }, "q", awesome.quit, + { description = "quitter", group = "awesome" }), + + awful.key({ modkey }, "j", function() awful.client.focus.byidx(1) end), + awful.key({ modkey }, "k", function() awful.client.focus.byidx(-1) end), + + awful.key({ modkey }, "Left", awful.tag.viewprev), + awful.key({ modkey }, "Right", awful.tag.viewnext), + + awful.key({ modkey }, "p", function() awful.spawn("rofi -show drun") + end, {description = "lancer rofi", group = "launcher"}) +) + +-- Navigation tags Super+1..9 +for i = 1, 9 do + global_keys = gears.table.join(global_keys, + awful.key({ modkey }, "#" .. i + 9, function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then tag:view_only() end + end, + { description = "aller au tag " .. i, group = "tag" }) + ) +end + +root.keys(global_keys) + +-- Raccourcis sur les fenêtres +local client_keys = gears.table.join( + awful.key({ modkey }, "q", function(c) c:kill() end, + { description = "fermer", group = "client" }), + + awful.key({ modkey }, "f", function(c) + c.fullscreen = not c.fullscreen + c:raise() + end), + + awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle) +) + +-- Boutons souris sur les fenêtres +local client_buttons = gears.table.join( + awful.button({}, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + end), + awful.button({ modkey }, 1, awful.mouse.client.move), + awful.button({ modkey }, 3, awful.mouse.client.resize) +) + +-- On exporte pour rules.lua +return { + client_keys = client_keys, + client_buttons = client_buttons, +} diff --git a/awesome/modules/rules.lua b/awesome/modules/rules.lua new file mode 100644 index 0000000..f2df4fe --- /dev/null +++ b/awesome/modules/rules.lua @@ -0,0 +1,16 @@ +local awful = require("awful") +local keys = require("modules.keys") + +awful.rules.rules = { + { + rule = {}, + properties = { + focus = awful.client.focus.filter, + raise = true, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap + awful.placement.no_offscreen, + keys = keys.client_keys, + buttons = keys.client_buttons, + } + }, +} diff --git a/awesome/modules/signals.lua b/awesome/modules/signals.lua new file mode 100644 index 0000000..891f8ed --- /dev/null +++ b/awesome/modules/signals.lua @@ -0,0 +1,13 @@ +local awful = require("awful") + +awful.rules.rules = { + { + rule = {}, + properties = { + focus = awful.client.focus.filter, + raise = true, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap + awful.placement.no_offscreen, + } + }, +} diff --git a/awesome/modules/tags.lua b/awesome/modules/tags.lua new file mode 100644 index 0000000..6b35fb6 --- /dev/null +++ b/awesome/modules/tags.lua @@ -0,0 +1,19 @@ +local awful = require("awful") + +local M = {} + +function M.setup(layouts) + awful.screen.connect_for_each_screen(function(s) + awful.tag({ "1", "2", "3", "4" }, s, layouts[1]) + + -- s.name peut être nil selon la version, on utilise s.index comme fallback + local monitor = s.name or ("screen" .. s.index) + awful.spawn.with_shell("MONITOR=" .. monitor .. " polybar main 2>/dev/null &") + end) + + awesome.connect_signal("startup", function() + awful.spawn.with_shell("killall -q polybar; sleep 0.5 && ~/.config/polybar/launch.sh") + end) +end + +return M diff --git a/awesome/rc.lua b/awesome/rc.lua new file mode 100644 index 0000000..fe672ab --- /dev/null +++ b/awesome/rc.lua @@ -0,0 +1,20 @@ +local gears = require("gears") +local awful = require("awful") +local beautiful = require("beautiful") +require("awful.autofocus") + +beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua") + +terminal = "alacritty" +modkey = "Mod4" + +awful.layout.layouts = { + awful.layout.suit.tile, + awful.layout.suit.floating, +} + +-- Chargement des modules +require("modules.tags").setup(awful.layout.layouts) +require("modules.keys") +require("modules.rules") +require("modules.signals") diff --git a/polybar/launch.sh b/polybar/launch.sh new file mode 100755 index 0000000..b89b0d2 --- /dev/null +++ b/polybar/launch.sh @@ -0,0 +1,6 @@ +#!/bin/sh +killall -q polybar + +while pgrep -x polybar >/dev/null; do sleep 1; done + +polybar -c ~/.config/polybar/main.ini main & diff --git a/polybar/main.ini b/polybar/main.ini new file mode 100644 index 0000000..7ede0cf --- /dev/null +++ b/polybar/main.ini @@ -0,0 +1,130 @@ +[bar/main] +width = 100% +height = 80 +background = #11111b +foreground = #cdd6f4 +font-0 = "FiraCode Nerd Font:size=20;4" + +modules-left = logo filesystem memory cpu +modules-center = date +modules-right = battery network power + +; ---------------------------- +; Demi-cercles +; ---------------------------- +[module/bar-left] +type = custom/text +content =  +content-font = 2 +content-foreground = #11111b +content-background = #00000000 + +[module/bar-right] +type = custom/text +content =  +content-font = 2 +content-foreground = #11111b +content-background = #00000000 + +; ---------------------------- +; Logo Debian cercle +; ---------------------------- +[module/logo-left] +type = custom/text +content =  +content-font = 2 +content-foreground = #89b4fa +content-background = #00000000 + +[module/logo] +type = custom/text +content =  +content-font = 2 +content-foreground = #11111b +content-background = #89b4fa + +[module/logo-right] +type = custom/text +content =  +content-font = 2 +content-foreground = #89b4fa +content-background = #00000000 + +; ---------------------------- +; Workspaces GP/CS/IT/IA +; ---------------------------- +[module/workspaces] +type = internal/xworkspaces +label-focused = %name% +label-occupied = %name% +label-empty = %name% +label-urgent = %name%! +label-padding = 1 +label-background-focused = #fab387 +label-background-occupied = #cdd6f4 +label-background-empty = #6c7086 +label-background-urgent = #f38ba8 + +; ---------------------------- +; Modules système +; ---------------------------- +[module/cpu] +type = internal/cpu +interval = 2 +label = [CPU %percentage%%] +label-padding = 1 +label-font = 2 +label-foreground = #f9e2af + +[module/memory] +type = internal/memory +interval = 2 +label = [RAM %percentage_used%%] +label-padding = 1 +label-foreground = #cba6f7 + +[module/date] +type = internal/date +interval = 60 +date = %H:%M +label-padding = 1 +label-foreground = #cdd6f4 + +[module/battery] +type = internal/battery +full-at = 98 +low-at = 10 +battery = BAT1 +adapter = ADP1 +poll-interval = 5 +label-charging = [battery %percentage%%] +label-discharging = [battery %percentage%%] +label-full = [battery Full] +label-low = [battery low] +label-padding = 1 +label-charging-foreground = #ffffcc00 +label-discharging-foreground = #ffffcc00 +label-full-foreground = #ffb3ff00 +label-low-foreground = #ffff4d00 + +[module/filesystem] +type = internal/fs +interval = 5 +fixed-values = true +label-mounted = [disk %percentage_used%%] +label-padding = 1 +label-mounted-foreground = #ffff0090 + +[module/power] +type = custom/script +exec = echo "[  ]" +click-left = ~/.config/polybar/scripts/powermenu.sh +interval = 0 + +[module/network] +type = internal/network +interface = wlp0s20f3 +label-connected = [wifi %netspeed%] +label-connected-foreground = #ff00ccff +label-disconnected = Disconnected +label-disconnected-foreground = #ffff3300 diff --git a/polybar/scripts/powermenu.sh b/polybar/scripts/powermenu.sh new file mode 100755 index 0000000..3607a6b --- /dev/null +++ b/polybar/scripts/powermenu.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +options="⏻ Éteindre\n Redémarrer\n Veille\n Déconnexion" + +chosen=$(echo -e "$options" | rofi -dmenu -i -p "Power") + +case "$chosen" in + *Éteindre) + systemctl poweroff + ;; + *Redémarrer) + systemctl reboot + ;; + *Veille) + systemctl suspend + ;; + *Déconnexion) + awesome-client 'awesome.quit()' + ;; +esac + diff --git a/rofi/config.rasi b/rofi/config.rasi new file mode 100644 index 0000000..4ebca0b --- /dev/null +++ b/rofi/config.rasi @@ -0,0 +1,155 @@ +configuration { +/* modes: "window,drun,run,ssh";*/ +/* font: "mono 12";*/ +/* location: 0;*/ +/* yoffset: 0;*/ +/* xoffset: 0;*/ +/* fixed-num-lines: true;*/ +/* show-icons: false;*/ +/* terminal: "rofi-sensible-terminal";*/ +/* ssh-client: "ssh";*/ +/* ssh-command: "{terminal} -e {ssh-client} {host} [-p {port}]";*/ +/* run-command: "{cmd}";*/ +/* run-list-command: "";*/ +/* run-shell-command: "{terminal} -e {cmd}";*/ +/* window-command: "wmctrl -i -R {window}";*/ +/* window-match-fields: "all";*/ +/* icon-theme: ;*/ +/* drun-match-fields: "name,generic,exec,categories,keywords";*/ +/* drun-categories: ;*/ +/* drun-show-actions: false;*/ +/* drun-display-format: "{name} [({generic})]";*/ +/* drun-url-launcher: "xdg-open";*/ +/* disable-history: false;*/ +/* ignored-prefixes: "";*/ +/* sort: false;*/ +/* sorting-method: "normal";*/ +/* case-sensitive: false;*/ +/* cycle: true;*/ +/* sidebar-mode: false;*/ +/* hover-select: false;*/ +/* eh: 1;*/ +/* auto-select: false;*/ +/* parse-hosts: false;*/ +/* parse-known-hosts: true;*/ +/* combi-modes: "window,run";*/ +/* matching: "normal";*/ +/* tokenize: true;*/ +/* m: "-5";*/ +/* filter: ;*/ +/* dpi: -1;*/ +/* threads: 0;*/ +/* scroll-method: 0;*/ +/* window-format: "{w} {c} {t}";*/ +/* click-to-exit: true;*/ +/* max-history-size: 25;*/ +/* combi-hide-mode-prefix: false;*/ +/* combi-display-format: "{mode} {text}";*/ +/* matching-negate-char: '-' /* unsupported */;*/ +/* cache-dir: ;*/ +/* window-thumbnail: false;*/ +/* drun-use-desktop-cache: false;*/ +/* drun-reload-desktop-cache: false;*/ +/* normalize-match: false;*/ +/* steal-focus: false;*/ +/* application-fallback-icon: ;*/ +/* refilter-timeout-limit: 8192;*/ +/* xserver-i300-workaround: false;*/ +/* pid: "/run/user/1000/rofi.pid";*/ +/* display-window: ;*/ +/* display-windowcd: ;*/ +/* display-run: ;*/ +/* display-ssh: ;*/ +/* display-drun: ;*/ +/* display-combi: ;*/ +/* display-keys: ;*/ +/* display-filebrowser: ;*/ +/* kb-primary-paste: "Control+V,Shift+Insert";*/ +/* kb-secondary-paste: "Control+v,Insert";*/ +/* kb-clear-line: "Control+w";*/ +/* kb-move-front: "Control+a";*/ +/* kb-move-end: "Control+e";*/ +/* kb-move-word-back: "Alt+b,Control+Left";*/ +/* kb-move-word-forward: "Alt+f,Control+Right";*/ +/* kb-move-char-back: "Left,Control+b";*/ +/* kb-move-char-forward: "Right,Control+f";*/ +/* kb-remove-word-back: "Control+Alt+h,Control+BackSpace";*/ +/* kb-remove-word-forward: "Control+Alt+d";*/ +/* kb-remove-char-forward: "Delete,Control+d";*/ +/* kb-remove-char-back: "BackSpace,Shift+BackSpace,Control+h";*/ +/* kb-remove-to-eol: "Control+k";*/ +/* kb-remove-to-sol: "Control+u";*/ +/* kb-accept-entry: "Control+j,Control+m,Return,KP_Enter";*/ +/* kb-accept-custom: "Control+Return";*/ +/* kb-accept-custom-alt: "Control+Shift+Return";*/ +/* kb-accept-alt: "Shift+Return";*/ +/* kb-delete-entry: "Shift+Delete";*/ +/* kb-mode-next: "Shift+Right,Control+Tab";*/ +/* kb-mode-previous: "Shift+Left,Control+ISO_Left_Tab";*/ +/* kb-mode-complete: "Control+l";*/ +/* kb-row-left: "Control+Page_Up";*/ +/* kb-row-right: "Control+Page_Down";*/ +/* kb-row-up: "Up,Control+p";*/ +/* kb-row-down: "Down,Control+n";*/ +/* kb-row-tab: "";*/ +/* kb-element-next: "Tab";*/ +/* kb-element-prev: "ISO_Left_Tab";*/ +/* kb-page-prev: "Page_Up";*/ +/* kb-page-next: "Page_Down";*/ +/* kb-row-first: "Home,KP_Home";*/ +/* kb-row-last: "End,KP_End";*/ +/* kb-row-select: "Control+space";*/ +/* kb-screenshot: "Alt+S";*/ +/* kb-ellipsize: "Alt+period";*/ +/* kb-toggle-case-sensitivity: "grave,dead_grave";*/ +/* kb-toggle-sort: "Alt+grave";*/ +/* kb-cancel: "Escape,Control+g,Control+bracketleft";*/ +/* kb-custom-1: "Alt+1";*/ +/* kb-custom-2: "Alt+2";*/ +/* kb-custom-3: "Alt+3";*/ +/* kb-custom-4: "Alt+4";*/ +/* kb-custom-5: "Alt+5";*/ +/* kb-custom-6: "Alt+6";*/ +/* kb-custom-7: "Alt+7";*/ +/* kb-custom-8: "Alt+8";*/ +/* kb-custom-9: "Alt+9";*/ +/* kb-custom-10: "Alt+0";*/ +/* kb-custom-11: "Alt+exclam";*/ +/* kb-custom-12: "Alt+at";*/ +/* kb-custom-13: "Alt+numbersign";*/ +/* kb-custom-14: "Alt+dollar";*/ +/* kb-custom-15: "Alt+percent";*/ +/* kb-custom-16: "Alt+dead_circumflex";*/ +/* kb-custom-17: "Alt+ampersand";*/ +/* kb-custom-18: "Alt+asterisk";*/ +/* kb-custom-19: "Alt+parenleft";*/ +/* kb-select-1: "Super+1";*/ +/* kb-select-2: "Super+2";*/ +/* kb-select-3: "Super+3";*/ +/* kb-select-4: "Super+4";*/ +/* kb-select-5: "Super+5";*/ +/* kb-select-6: "Super+6";*/ +/* kb-select-7: "Super+7";*/ +/* kb-select-8: "Super+8";*/ +/* kb-select-9: "Super+9";*/ +/* kb-select-10: "Super+0";*/ +/* ml-row-left: "ScrollLeft";*/ +/* ml-row-right: "ScrollRight";*/ +/* ml-row-up: "ScrollUp";*/ +/* ml-row-down: "ScrollDown";*/ +/* me-select-entry: "MousePrimary";*/ +/* me-accept-entry: "MouseDPrimary";*/ +/* me-accept-custom: "Control+MouseDPrimary";*/ + timeout { + action: "kb-cancel"; + delay: 0; + } + filebrowser { + directories-first: true; + sorting-method: "name"; + } + dump { + config: ">"; + } +} +