From 2ebe28b87eeeb8f875a75ebdaa785b46c61bf50a Mon Sep 17 00:00:00 2001 From: ABeltramo Date: Sat, 6 Jul 2024 15:15:49 +0100 Subject: [PATCH] feat: Sway cleanup, added terminal, better defaults, xdg-desktop-portal --- images/base-app/Dockerfile | 3 +- images/base-app/configs/sway/config | 17 +- images/base-app/configs/waybar/config.jsonc | 100 +++++++ images/base-app/configs/waybar/style.css | 296 ++++++++++++++++++++ images/base-app/scripts/launch-comp.sh | 18 +- images/steam/scripts/startup.sh | 2 +- 6 files changed, 431 insertions(+), 5 deletions(-) create mode 100644 images/base-app/configs/waybar/config.jsonc create mode 100644 images/base-app/configs/waybar/style.css diff --git a/images/base-app/Dockerfile b/images/base-app/Dockerfile index 6038a723..8ba0831f 100644 --- a/images/base-app/Dockerfile +++ b/images/base-app/Dockerfile @@ -99,7 +99,8 @@ _INSTALL_GAMESCOPE # Install Sway ################################# RUN apt-get update -y && \ - apt-get install -y sway waybar fonts-font-awesome xwayland && \ + apt-get install -y sway xwayland kitty nano \ + waybar fonts-font-awesome xdg-desktop-portal xdg-desktop-portal-gtk psmisc && \ rm -rf /var/lib/apt/lists/* COPY configs /cfg diff --git a/images/base-app/configs/sway/config b/images/base-app/configs/sway/config index c0652bc2..0e5a1460 100644 --- a/images/base-app/configs/sway/config +++ b/images/base-app/configs/sway/config @@ -38,7 +38,7 @@ include /etc/sway/config-vars.d/* # Basics: # # Start a terminal - # bindsym $mod+Return exec $term + bindsym $mod+Return exec kitty # Kill focused window # Cemu doesn't have a close button on some of its menus (sway doesn't support those button types yet) @@ -87,6 +87,21 @@ mode "resize" { include /etc/sway/config.d/* +# Font, borders, and gaps + gaps inner 4 + gaps outer -4 + gaps top -2 + gaps bottom 0 + default_border pixel 2 + default_floating_border pixel 2 + +# Colours + client.background n/a #434c5e n/a + client.focused #4C566A #434c5e #eceff4 #434c5e #434c5e + client.focused_inactive #3b4252 #3b4252 #eceff4 #3b4252 #3b4252 + client.unfocused #3b4252 #3b4252 #eceff4 #3b4252 #3b4252 + client.urgent #4C566A #434c5e #eceff4 #434c5e #434c5e + bar swaybar_command waybar # Need to autostart something after this line, for example: diff --git a/images/base-app/configs/waybar/config.jsonc b/images/base-app/configs/waybar/config.jsonc new file mode 100644 index 00000000..351c1f92 --- /dev/null +++ b/images/base-app/configs/waybar/config.jsonc @@ -0,0 +1,100 @@ +// -*- mode: jsonc -*- +{ + "layer": "top", // Waybar at top layer + "position": "top", // Waybar position (top|bottom|left|right) + "height": 30, // Waybar height (to be removed for auto height) + // "width": 1280, // Waybar width + "spacing": 4, // Gaps between modules (4px) + // Choose the order of the modules + "modules-left": [ + "sway/workspaces", + "sway/mode", + "sway/scratchpad", + "custom/kitty" + ], + "modules-center": [ + "sway/window" + ], + "modules-right": [ + "pulseaudio", + "network", + "cpu", + "memory", + "temperature", + "sway/language", + "clock" + ], + "custom/kitty": { + "format": "{} ", + "tooltip": false, + "on-click": "kitty" + }, + "sway/mode": { + "format": "{}" + }, + "sway/scratchpad": { + "format": "{icon} {count}", + "show-empty": false, + "format-icons": ["", ""], + "tooltip": true, + "tooltip-format": "{app}: {title}" + }, + "idle_inhibitor": { + "format": "{icon}", + "format-icons": { + "activated": "", + "deactivated": "" + } + }, + "tray": { + // "icon-size": 21, + "spacing": 10 + }, + "clock": { + // "timezone": "America/New_York", + "tooltip-format": "{:%Y %B}\n{calendar}", + "format-alt": "{:%Y-%m-%d}" + }, + "cpu": { + "format": "{usage}% ", + "tooltip": false + }, + "memory": { + "format": "{}% " + }, + "temperature": { + // "thermal-zone": 2, + // "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input", + "critical-threshold": 80, + // "format-critical": "{temperatureC}°C {icon}", + "format": "{temperatureC}°C", + "format-icons": ["", "", ""] + }, + "network": { + // "interface": "wlp2*", // (Optional) To force the use of this interface + "format-wifi": "{essid} ({signalStrength}%) ", + "format-ethernet": "{ipaddr}/{cidr}", + "tooltip-format": "{ifname} via {gwaddr}", + "format-linked": "{ifname} (No IP)", + "format-disconnected": "Disconnected ⚠", + "format-alt": "{ifname}: {ipaddr}/{cidr}" + }, + "pulseaudio": { + // "scroll-step": 1, // %, can be a float + "format": "{volume}% {icon} {format_source}", + "format-bluetooth": "{volume}% {icon} {format_source}", + "format-bluetooth-muted": " {icon} {format_source}", + "format-muted": " {format_source}", + "format-source": "{volume}% ", + "format-source-muted": "", + "format-icons": { + "headphone": "", + "hands-free": "", + "headset": "", + "phone": "", + "portable": "", + "car": "", + "default": ["", "", ""] + } + } +} diff --git a/images/base-app/configs/waybar/style.css b/images/base-app/configs/waybar/style.css new file mode 100644 index 00000000..40051e80 --- /dev/null +++ b/images/base-app/configs/waybar/style.css @@ -0,0 +1,296 @@ +/* TAKEN FROM: https://github.com/Pipshag/dotfiles_nord/tree/master/.config/waybar */ +@keyframes blink-warning { + 70% { + color: @light; + } + + to { + color: @light; + background-color: @warning; + } +} + +@keyframes blink-critical { + 70% { + color: @light; + } + + to { + color: @light; + background-color: @critical; + } +} + + +/* ----------------------------------------------------------------------------- + * Styles + * -------------------------------------------------------------------------- */ + +/* COLORS */ + +/* Nord */ +@define-color bg #2E3440; +/*@define-color bg #353C4A;*/ +@define-color light #D8DEE9; +/*@define-color dark @nord_dark_font;*/ +@define-color warning #ebcb8b; +@define-color critical #BF616A; +@define-color mode #434C5E; +/*@define-color workspaces @bg;*/ +/*@define-color workspaces @nord_dark_font;*/ +/*@define-color workspacesfocused #434C5E;*/ +@define-color workspacesfocused #4C566A; +@define-color tray @workspacesfocused; +@define-color sound #EBCB8B; +@define-color network #5D7096; +@define-color memory #546484; +@define-color cpu #596A8D; +@define-color temp #4D5C78; +@define-color layout #5e81ac; +@define-color battery #88c0d0; +@define-color date #434C5E; +@define-color time #434C5E; +@define-color backlight #434C5E; +@define-color nord_bg #434C5E; +@define-color nord_bg_blue #546484; +@define-color nord_light #D8DEE9; +@define-color nord_light_font #D8DEE9; +@define-color nord_dark_font #434C5E; + +/* Reset all styles */ +* { + border: none; + border-radius: 3px; + min-height: 0; + margin: 0.2em 0.3em 0.2em 0.3em; +} + +/* The whole bar */ +#waybar { + background: @bg; + color: @light; + font-family: "Cantarell", "Font Awesome 5 Pro"; + font-size: 12px; + font-weight: bold; +} + +/* Each module */ +#battery, +#clock, +#cpu, +#custom-layout, +#memory, +#mode, +#network, +#pulseaudio, +#temperature, +#custom-alsa, +#custom-pacman, +#custom-weather, +#custom-gpu, +#tray, +#backlight, +#language, +#custom-cpugovernor { + padding-left: 0.6em; + padding-right: 0.6em; +} + +/* Each module that should blink */ +#mode, +#memory, +#temperature, +#battery { + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +/* Each critical module */ +#memory.critical, +#cpu.critical, +#temperature.critical, +#battery.critical { + color: @critical; +} + +/* Each critical that should blink */ +#mode, +#memory.critical, +#temperature.critical, +#battery.critical.discharging { + animation-name: blink-critical; + animation-duration: 2s; +} + +/* Each warning */ +#network.disconnected, +#memory.warning, +#cpu.warning, +#temperature.warning, +#battery.warning { + background: @warning; + color: @nord_dark_font; +} + +/* Each warning that should blink */ +#battery.warning.discharging { + animation-name: blink-warning; + animation-duration: 3s; +} + +/* And now modules themselves in their respective order */ + +#mode { /* Shown current Sway mode (resize etc.) */ + color: @light; + background: @mode; +} + +/* Workspaces stuff */ + +#workspaces { + /* color: #D8DEE9; + margin-right: 10px;*/ +} + +#workspaces button { + font-weight: bold; /* Somewhy the bar-wide setting is ignored*/ + padding: 0; + /*color: #999;*/ + opacity: 0.3; + background: none; + font-size: 1em; +} + +#workspaces button.focused { + background: @workspacesfocused; + color: #D8DEE9; + opacity: 1; + padding: 0 0.4em; +} + +#workspaces button.urgent { + border-color: #c9545d; + color: #c9545d; + opacity: 1; +} + +#window { + margin-right: 40px; + margin-left: 40px; + font-weight: normal; +} +#bluetooth { + background: @nord_bg_blue; + font-size: 1.2em; + font-weight: bold; + padding: 0 0.6em; +} +#custom-gpu { + background: @nord_bg; + font-weight: bold; + padding: 0 0.6em; +} +#custom-weather { + background: @mode; + font-weight: bold; + padding: 0 0.6em; +} +#custom-pacman { + background: @nord_light; + color: @nord_dark_font; + font-weight: bold; + padding: 0 0.6em; +} +#custom-scratchpad-indicator { + background: @nord_light; + color: @nord_dark_font; + font-weight: bold; + padding: 0 0.6em; +} +#idle_inhibitor { + background: @mode; + /*font-size: 1.6em;*/ + font-weight: bold; + padding: 0 0.6em; +} +#custom-alsa { + background: @sound; +} + +#network { + background: @nord_bg_blue; +} + +#memory { + background: @memory; +} + +#cpu { + background: @nord_bg; + color: #D8DEE9; +} +#cpu.critical { + color: @nord_dark_font; +} +#language { + background: @nord_bg_blue; + color: #D8DEE9; + padding: 0 0.4em; +} +#custom-cpugovernor { + background-color: @nord_light; + color: @nord_dark_font; +} +#custom-cpugovernor.perf { + +} +#temperature { + background-color: @nord_bg; + color: #D8DEE9; +} +#temperature.critical { + background: @critical; +} +#custom-layout { + background: @layout; +} + +#battery { + background: @battery; +} + +#backlight { + background: @backlight; +} + +#clock { + background: @nord_bg_blue; + color: #D8DEE9; +} +#clock.date { + background: @date; +} + +#clock.time { + background: @mode; +} + +#pulseaudio { /* Unsused but kept for those who needs it */ + background: @nord_bg_blue; + color: #D8DEE9; +} + +#pulseaudio.muted { + background: #BF616A; + color: #BF616A; + /* No styles */ +} +#pulseaudio.source-muted { + background: #D08770; + color: #D8DEE9; + /* No styles */ +} +#tray { + background: #434C5E; +} diff --git a/images/base-app/scripts/launch-comp.sh b/images/base-app/scripts/launch-comp.sh index 4af15479..532c4973 100755 --- a/images/base-app/scripts/launch-comp.sh +++ b/images/base-app/scripts/launch-comp.sh @@ -16,12 +16,26 @@ function launcher() { elif [ -n "$RUN_SWAY" ]; then gow_log "[Sway] - Starting: \`$@\`" - export XDG_SESSION_TYPE=wayland + export SWAY_STOP_ON_APP_EXIT=${SWAY_STOP_ON_APP_EXIT:-"yes"} + export XDG_CURRENT_DESKTOP=sway # xdg-desktop-portal + export XDG_SESSION_DESKTOP=sway # systemd + export XDG_SESSION_TYPE=wayland # xdg/systemd + + # Only copy waybar default config if it doesn't exist + mkdir -p $HOME/.config/waybar + cp -u /cfg/waybar/* $HOME/.config/waybar/ + + # Sway needs to be overridden since we are going to change the resolution and app start mkdir -p $HOME/.config/sway/ cp /cfg/sway/config $HOME/.config/sway/config # Modify the config file for res and to launch the app at the end echo "output * resolution ${GAMESCOPE_WIDTH}x${GAMESCOPE_HEIGHT} position 0,0" >> $HOME/.config/sway/config - echo "workspace main; exec $@" >> $HOME/.config/sway/config + echo -n "workspace main; exec $@" >> $HOME/.config/sway/config + + # if SWAY_STOP_ON_APP_EXIT == "yes" then kill sway when the app exits + if [ "$SWAY_STOP_ON_APP_EXIT" == "yes" ]; then + echo -n " && killall sway" >> $HOME/.config/sway/config + fi # Start sway dbus-run-session -- sway --unsupported-gpu diff --git a/images/steam/scripts/startup.sh b/images/steam/scripts/startup.sh index 936dceb0..1ae5512f 100755 --- a/images/steam/scripts/startup.sh +++ b/images/steam/scripts/startup.sh @@ -3,7 +3,7 @@ set -e source /opt/gow/bash-lib/utils.sh -gow_log "Starting Steam with DISPLAY=${DISPLAY}" +gow_log "Steam startup.sh" # Recursively creating Steam necessary folders (https://github.com/ValveSoftware/steam-for-linux/issues/6492) mkdir -p "$HOME/.steam/ubuntu12_32/steam-runtime"