From 9e68a836fd03a40b591b9b24b19797d1c88c253d Mon Sep 17 00:00:00 2001
From: Andreas Gerlach <andi@appelgriebsch.org>
Date: Wed, 29 Jul 2020 22:42:31 +0200
Subject: [PATCH] [sway] rework theming and config to prevent broken configs
 from package updates

---
 .../sway/config.d/99-autostart-applications   |   2 +-
 overlays/sway/etc/sway/definitions            |  19 +-
 overlays/sway/etc/sway/outputs/default-screen |   2 +-
 .../sway/etc/sway/themes/matcha-blue/mako     |  13 ++
 .../sway/etc/sway/themes/matcha-blue/sway     |  31 +++
 .../sway/etc/sway/themes/matcha-blue/termite  | 104 +++++++++
 .../sway/etc/sway/themes/matcha-blue/waybar   | 217 ++++++++++++++++++
 .../sway/etc/sway/themes/matcha-blue/wofi     |  16 ++
 .../config => sway/themes/matcha-green/mako}  |   0
 .../sway/themes/{matcha => matcha-green/sway} |   0
 .../themes/matcha-green/termite}              |   0
 .../themes/matcha-green/waybar}               |   0
 .../themes/matcha-green/wofi}                 |   2 +-
 overlays/sway/etc/{xdg => sway}/waybar/config |   0
 overlays/sway/etc/{xdg => sway}/wofi/config   |   0
 .../{xdg/wofi/overlay => sway/wofi/swhelp}    |   0
 overlays/sway/usr/local/bin/launch_waybar.sh  |   4 +
 overlays/sway/usr/local/bin/swhelp.sh         |   6 +-
 18 files changed, 400 insertions(+), 16 deletions(-)
 create mode 100644 overlays/sway/etc/sway/themes/matcha-blue/mako
 create mode 100644 overlays/sway/etc/sway/themes/matcha-blue/sway
 create mode 100644 overlays/sway/etc/sway/themes/matcha-blue/termite
 create mode 100644 overlays/sway/etc/sway/themes/matcha-blue/waybar
 create mode 100644 overlays/sway/etc/sway/themes/matcha-blue/wofi
 rename overlays/sway/etc/{xdg/mako/config => sway/themes/matcha-green/mako} (100%)
 rename overlays/sway/etc/sway/themes/{matcha => matcha-green/sway} (100%)
 rename overlays/sway/etc/{xdg/termite/config => sway/themes/matcha-green/termite} (100%)
 rename overlays/sway/etc/{xdg/waybar/style.css => sway/themes/matcha-green/waybar} (100%)
 rename overlays/sway/etc/{xdg/wofi/style.css => sway/themes/matcha-green/wofi} (91%)
 rename overlays/sway/etc/{xdg => sway}/waybar/config (100%)
 rename overlays/sway/etc/{xdg => sway}/wofi/config (100%)
 rename overlays/sway/etc/{xdg/wofi/overlay => sway/wofi/swhelp} (100%)
 create mode 100755 overlays/sway/usr/local/bin/launch_waybar.sh

diff --git a/overlays/sway/etc/sway/config.d/99-autostart-applications b/overlays/sway/etc/sway/config.d/99-autostart-applications
index 8719536f..3e65e448 100644
--- a/overlays/sway/etc/sway/config.d/99-autostart-applications
+++ b/overlays/sway/etc/sway/config.d/99-autostart-applications
@@ -12,7 +12,7 @@ exec systemctl --user import-environment && gnome-keyring-daemon --components=ss
 
 # autostart background applications
 exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
-exec --no-startup-id mako --config /etc/xdg/mako/config
+exec --no-startup-id mako --config $theme/mako
 exec --no-startup-id pamac-tray-appindicator
 exec --no-startup-id nm-applet --indicator
 exec --no-startup-id blueman-applet
diff --git a/overlays/sway/etc/sway/definitions b/overlays/sway/etc/sway/definitions
index 43969cf2..9e005347 100644
--- a/overlays/sway/etc/sway/definitions
+++ b/overlays/sway/etc/sway/definitions
@@ -9,20 +9,21 @@ set $down j
 set $up k
 set $right l
 
-# styles
-set $theme /etc/sway/themes/matcha
+# styles - matcha-green or matcha-blue
+set $theme /etc/sway/themes/matcha-green
+
 set $background /usr/share/wallpapers/manjaro-arm/generic/manjaro-arm2.png
 
 # Your preferred terminal emulator
-set $term termite
+set $term termite --config $theme/termite
 
 # Your preferred application launcher
 # Note: pass the final command to swaymsg so that the resulting window can be opened
 # on the original workspace that the command was run on.
-set $appmenu wofi --show drun --conf /etc/xdg/wofi/config --style /etc/xdg/wofi/style.css --prompt "Application Launcher" | xargs swaymsg exec --
-set $menu wofi --show run --conf /etc/xdg/wofi/config --style /etc/xdg/wofi/style.css --exec-search --prompt "Run Command" | xargs swaymsg exec --
-set $selwin sws.sh --dmenu-cmd "wofi --conf /etc/xdg/wofi/config --style /etc/xdg/wofi/style.css --show dmenu" --format "%W | %A - %T"
-set $help swhelp.sh
+set $appmenu wofi --show drun --conf /etc/sway/wofi/config --style $theme/wofi --prompt "Application Launcher" | xargs swaymsg exec --
+set $menu wofi --show run --conf /etc/sway/wofi/config --style $theme/wofi --exec-search --prompt "Run Command" | xargs swaymsg exec --
+set $selwin sws.sh --dmenu-cmd "wofi --conf /etc/sway/wofi/config --style $theme/wofi --show dmenu" --format "%W | %A - %T"
+set $help swhelp.sh --conf /etc/sway/wofi/swhelp --style $theme/wofi --location 7 --xoffset 10 --yoffset -10
 
 ### Idle configuration
 # This will lock your screen after 300 seconds of inactivity, then turn off
@@ -35,8 +36,8 @@ set $idle swayidle -w \
     resume 'swaymsg "output * dpms on"' \
     before-sleep 'swaylock -f -c 000000'
 
-# Statusbar command
-set $statusbar waybar
+# statusbar command
+set $statusbar launch_waybar.sh
 
 # logout command
 set $logout wlogout --layout /etc/wlogout/user-loggedin
diff --git a/overlays/sway/etc/sway/outputs/default-screen b/overlays/sway/etc/sway/outputs/default-screen
index 785f14e5..36f60f66 100644
--- a/overlays/sway/etc/sway/outputs/default-screen
+++ b/overlays/sway/etc/sway/outputs/default-screen
@@ -7,7 +7,7 @@
 # You can get the names of your outputs by running: swaymsg -t get_outputs
 
 # import theme
-include $theme
+include $theme/sway
 
 # Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
 output * bg $background fill
diff --git a/overlays/sway/etc/sway/themes/matcha-blue/mako b/overlays/sway/etc/sway/themes/matcha-blue/mako
new file mode 100644
index 00000000..ed303c88
--- /dev/null
+++ b/overlays/sway/etc/sway/themes/matcha-blue/mako
@@ -0,0 +1,13 @@
+# default config for the mako notification daemon
+
+layer=overlay
+width=400
+height=200
+font="Noto Sans 11"
+text-color=#141a1b
+background-color=#55b5db
+icons=1
+max-icon-size=48
+markup=1
+actions=1
+default-timeout=5000
diff --git a/overlays/sway/etc/sway/themes/matcha-blue/sway b/overlays/sway/etc/sway/themes/matcha-blue/sway
new file mode 100644
index 00000000..c582fe22
--- /dev/null
+++ b/overlays/sway/etc/sway/themes/matcha-blue/sway
@@ -0,0 +1,31 @@
+# based on Base16 Seti UI
+# Author: Appelgriebsch
+
+set $base00 #141a1b
+set $base01 #282a2b
+set $base02 #3B758C
+set $base03 #41535B
+set $base04 #43a5d5
+set $base05 #d6d6d6
+set $base06 #eeeeee
+set $base07 #ffffff
+set $base08 #Cd3f45
+set $base09 #db7b55
+set $base0A #e6cd69
+set $base0B #9fca56
+set $base0C #16a085
+set $base0D #55b5db
+set $base0E #a074c4
+set $base0F #8a553f
+
+default_border pixel 1
+hide_edge_borders smart
+
+# Basic color configuration using the Base16 variables for windows and borders.
+# Property Name         Border  BG      Text    Indicator Child Border
+client.focused          $base05 $base0D $base00 $base0D $base0D
+client.focused_inactive $base01 $base01 $base05 $base03 $base01
+client.unfocused        $base01 $base00 $base05 $base01 $base01
+client.urgent           $base08 $base08 $base00 $base08 $base08
+client.placeholder      $base00 $base00 $base05 $base00 $base00
+client.background       $base07
diff --git a/overlays/sway/etc/sway/themes/matcha-blue/termite b/overlays/sway/etc/sway/themes/matcha-blue/termite
new file mode 100644
index 00000000..76311a38
--- /dev/null
+++ b/overlays/sway/etc/sway/themes/matcha-blue/termite
@@ -0,0 +1,104 @@
+[options]
+#allow_bold = true
+#audible_bell = false
+#bold_is_bright = true
+#cell_height_scale = 1.0
+#cell_width_scale = 1.0
+clickable_url = true
+dynamic_title = true
+font = TerminessTTF Nerd Font Mono 14
+#fullscreen = true
+#icon_name = terminal
+#mouse_autohide = false
+#scroll_on_output = false
+#scroll_on_keystroke = true
+# Length of the scrollback buffer, 0 disabled the scrollback buffer
+# and setting it to a negative value means "infinite scrollback"
+scrollback_lines = 10000
+#search_wrap = true
+#urgent_on_bell = true
+#hyperlinks = false
+
+# $BROWSER is used by default if set, with xdg-open as a fallback
+#browser = xdg-open
+
+# "system", "on" or "off"
+cursor_blink = on
+
+# "block", "underline" or "ibeam"
+cursor_shape = block
+
+# Hide links that are no longer valid in url select overlay mode
+#filter_unmatched_urls = true
+
+# Emit escape sequences for extra modified keys
+#modify_other_keys = false
+
+# set size hints for the window
+#size_hints = false
+
+# "off", "left" or "right"
+#scrollbar = off
+
+[hints]
+#font = Monospace 12
+#foreground = #dcdccc
+#background = #3f3f3f
+#active_foreground = #e68080
+#active_background = #3f3f3f
+#padding = 2
+#border = #3f3f3f
+#border_width = 0.5
+#roundness = 2.0
+
+[colors]
+# based on Base16 Seti UI
+# Author: Appelgriebsch
+
+foreground          = #d6d6d6
+foreground_bold     = #d6d6d6
+cursor              = #d6d6d6
+cursor_foreground   = #141a1b
+background          = rgba(20, 26, 27, 0.9)
+
+# 16 color space
+
+# Black, Gray, Silver, White
+color0  = #141a1b
+color8  = #41535B
+color7  = #d6d6d6
+color15 = #ffffff
+
+# Red
+color1  = #Cd3f45
+color9  = #Cd3f45
+
+# Green
+color2  = #9fca56
+color10 = #9fca56
+
+# Yellow
+color3  = #e6cd69
+color11 = #e6cd69
+
+# Blue
+color4  = #55b5db
+color12 = #55b5db
+
+# Purple
+color5  = #a074c4
+color13 = #a074c4
+
+# Teal
+color6  = #16a085
+color14 = #16a085
+
+# Extra colors
+color16 = #db7b55
+color17 = #8a553f
+color18 = #282a2b
+color19 = #3B758C
+color20 = #43a5d5
+color21 = #eeeeee
+
+# vim: ft=dosini cms=#%s
diff --git a/overlays/sway/etc/sway/themes/matcha-blue/waybar b/overlays/sway/etc/sway/themes/matcha-blue/waybar
new file mode 100644
index 00000000..3a6e479e
--- /dev/null
+++ b/overlays/sway/etc/sway/themes/matcha-blue/waybar
@@ -0,0 +1,217 @@
+/* =============================================================================
+ *
+ * Waybar configuration
+ *
+ * Configuration reference: https://github.com/Alexays/Waybar/wiki/Configuration
+ *
+ * =========================================================================== */
+
+/*
+*
+* based on Base16 Seti UI
+* Author: Appelgriebsch
+*
+*/
+
+@define-color base00 #141a1b;
+@define-color base01 #282a2b;
+@define-color base02 #3b758c;
+@define-color base03 #41535b;
+@define-color base04 #43a5d5;
+@define-color base05 #d6d6d6;
+@define-color base06 #eeeeee;
+@define-color base07 #ffffff;
+@define-color base08 #cd3f45;
+@define-color base09 #db7b55;
+@define-color base0A #e6cd69;
+@define-color base0B #9fca56;
+@define-color base0C #16a085;
+@define-color base0D #55b5db;
+@define-color base0E #a074c4;
+@define-color base0F #8a553f;
+
+
+/* -----------------------------------------------------------------------------
+ * Keyframes
+ * -------------------------------------------------------------------------- */
+
+@keyframes blink-warning {
+    70% {
+        color: @base07;
+    }
+
+    to {
+        color: @base07;
+        background-color: @base09;
+    }
+}
+
+@keyframes blink-critical {
+    70% {
+      color: @base07;
+    }
+
+    to {
+        color: @base07;
+        background-color: @base08;
+    }
+}
+
+
+/* -----------------------------------------------------------------------------
+ * Base styles
+ * -------------------------------------------------------------------------- */
+
+/* Reset all styles */
+* {
+    border: none;
+    border-radius: 0;
+    min-height: 0;
+    margin: 0;
+    padding: 0;
+    font-family: "FontAwesome 5 Free Solid", "Noto Sans", Roboto, sans-serif;
+}
+
+/* The whole bar */
+#waybar {
+    background: @base00;
+    color: @base07;
+    font-family: "Noto Sans", Roboto, sans-serif;
+    font-size: 13px;
+}
+
+/* Each module */
+#battery,
+#clock,
+#cpu,
+#custom-keyboard-layout,
+#memory,
+#mode,
+#network,
+#pulseaudio,
+#temperature,
+#tray {
+    padding-left: 10px;
+    padding-right: 10px;
+}
+
+
+/* -----------------------------------------------------------------------------
+ * Module styles
+ * -------------------------------------------------------------------------- */
+
+#battery {
+    animation-timing-function: linear;
+    animation-iteration-count: infinite;
+    animation-direction: alternate;
+}
+
+#battery.warning {
+    color: @base09;
+}
+
+#battery.critical {
+    color: @base08;
+}
+
+#battery.warning.discharging {
+    animation-name: blink-warning;
+    animation-duration: 3s;
+}
+
+#battery.critical.discharging {
+    animation-name: blink-critical;
+    animation-duration: 2s;
+}
+
+#clock {
+    font-weight: bold;
+}
+
+#cpu {
+  /* No styles */
+}
+
+#cpu.warning {
+    color: @base09;
+}
+
+#cpu.critical {
+    color: @base08;
+}
+
+#memory {
+    animation-timing-function: linear;
+    animation-iteration-count: infinite;
+    animation-direction: alternate;
+}
+
+#memory.warning {
+    color: @base09;
+}
+
+#memory.critical {
+    color: @base08;
+    animation-name: blink-critical;
+    animation-duration: 2s;
+}
+
+#mode {
+    background: @base01;
+}
+
+#network {
+    /* No styles */
+}
+
+#network.disconnected {
+    color: @base09;
+}
+
+#pulseaudio {
+    /* No styles */
+}
+
+#pulseaudio.muted {
+    /* No styles */
+}
+
+#custom-spotify {
+    color: @base0C;
+}
+
+#temperature {
+    /* No styles */
+}
+
+#temperature.critical {
+    color: @base08;
+}
+
+#tray {
+    /* No styles */
+}
+
+#window {
+    font-weight: bold;
+}
+
+#workspaces button {
+    border-top: 2px solid transparent;
+    /* To compensate for the top border and still have vertical centering */
+    padding-bottom: 2px;
+    padding-left: 10px;
+    padding-right: 10px;
+    color: @base05;
+}
+
+#workspaces button.focused {
+    border-color: @base0D;
+    color: @base07;
+    background-color: @base0D;
+}
+
+#workspaces button.urgent {
+    border-color: @base08;
+    color: @base08;
+}
diff --git a/overlays/sway/etc/sway/themes/matcha-blue/wofi b/overlays/sway/etc/sway/themes/matcha-blue/wofi
new file mode 100644
index 00000000..f03e754f
--- /dev/null
+++ b/overlays/sway/etc/sway/themes/matcha-blue/wofi
@@ -0,0 +1,16 @@
+#input {
+  border: none;
+  border-radius: 0px;
+}
+
+#text {
+  margin-left: 1em;
+}
+
+window {
+  opacity: 0.9;
+  border: 2px solid #55b5db;
+  background-color: #141a1b;
+  color: #ffffff;
+  border-radius: 5px;
+}
diff --git a/overlays/sway/etc/xdg/mako/config b/overlays/sway/etc/sway/themes/matcha-green/mako
similarity index 100%
rename from overlays/sway/etc/xdg/mako/config
rename to overlays/sway/etc/sway/themes/matcha-green/mako
diff --git a/overlays/sway/etc/sway/themes/matcha b/overlays/sway/etc/sway/themes/matcha-green/sway
similarity index 100%
rename from overlays/sway/etc/sway/themes/matcha
rename to overlays/sway/etc/sway/themes/matcha-green/sway
diff --git a/overlays/sway/etc/xdg/termite/config b/overlays/sway/etc/sway/themes/matcha-green/termite
similarity index 100%
rename from overlays/sway/etc/xdg/termite/config
rename to overlays/sway/etc/sway/themes/matcha-green/termite
diff --git a/overlays/sway/etc/xdg/waybar/style.css b/overlays/sway/etc/sway/themes/matcha-green/waybar
similarity index 100%
rename from overlays/sway/etc/xdg/waybar/style.css
rename to overlays/sway/etc/sway/themes/matcha-green/waybar
diff --git a/overlays/sway/etc/xdg/wofi/style.css b/overlays/sway/etc/sway/themes/matcha-green/wofi
similarity index 91%
rename from overlays/sway/etc/xdg/wofi/style.css
rename to overlays/sway/etc/sway/themes/matcha-green/wofi
index b2ff9c2d..eb1952e6 100644
--- a/overlays/sway/etc/xdg/wofi/style.css
+++ b/overlays/sway/etc/sway/themes/matcha-green/wofi
@@ -11,6 +11,6 @@ window {
   opacity: 0.9;
   border: 2px solid #16a085;
   background-color: #141a1b;
-  color: #ebf8ff;
+  color: #ffffff;
   border-radius: 5px;
 }
diff --git a/overlays/sway/etc/xdg/waybar/config b/overlays/sway/etc/sway/waybar/config
similarity index 100%
rename from overlays/sway/etc/xdg/waybar/config
rename to overlays/sway/etc/sway/waybar/config
diff --git a/overlays/sway/etc/xdg/wofi/config b/overlays/sway/etc/sway/wofi/config
similarity index 100%
rename from overlays/sway/etc/xdg/wofi/config
rename to overlays/sway/etc/sway/wofi/config
diff --git a/overlays/sway/etc/xdg/wofi/overlay b/overlays/sway/etc/sway/wofi/swhelp
similarity index 100%
rename from overlays/sway/etc/xdg/wofi/overlay
rename to overlays/sway/etc/sway/wofi/swhelp
diff --git a/overlays/sway/usr/local/bin/launch_waybar.sh b/overlays/sway/usr/local/bin/launch_waybar.sh
new file mode 100755
index 00000000..6c621160
--- /dev/null
+++ b/overlays/sway/usr/local/bin/launch_waybar.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+THEME_DIR=$(grep '^set $theme' /etc/sway/definitions | sed 's/set $theme //g')
+waybar --config /etc/sway/waybar/config --style $THEME_DIR/waybar
diff --git a/overlays/sway/usr/local/bin/swhelp.sh b/overlays/sway/usr/local/bin/swhelp.sh
index 89d282eb..fe50edd6 100755
--- a/overlays/sway/usr/local/bin/swhelp.sh
+++ b/overlays/sway/usr/local/bin/swhelp.sh
@@ -9,10 +9,8 @@ FIRST_RUN=$HOME/.firstrun
 
 if [ -f $PIDFILE ]; then exit 1; fi
 
-DMENU_OPT="--conf /etc/xdg/wofi/overlay --style /etc/xdg/wofi/style.css --location 7 --xoffset 10 --yoffset -10"
-
 spawn_help_overlay() {
-cat <<EOF | wofi --show dmenu $DMENU_OPT
+cat <<EOF | wofi --show dmenu "$@"
   <b>Manjaro ARM Sway Edition</b>
   Default Modifier: <b>Alt</b>
   New Terminal: <b>\$mod</b> + <b>Enter</b>
@@ -46,4 +44,4 @@ if [ "$AUTOSTART" == "YES" ]; then
 fi
 
 touch $PIDFILE
-spawn_help_overlay &
+spawn_help_overlay "$@" &
-- 
GitLab