From 1ae05e9bd14ac2455b30d01f6663b530e8c4ae63 Mon Sep 17 00:00:00 2001 From: Ivan Bushchik Date: Wed, 3 Aug 2022 13:22:50 +0300 Subject: [PATCH] Add sway configs --- README.md | 2 +- configs/sway/sway | 101 ++++++++++++++ configs/sway/waybar/config | 162 +++++++++++++++++++++ configs/sway/waybar/style.css | 255 ++++++++++++++++++++++++++++++++++ tools/install.sh | 7 +- tools/relink.sh | 17 +-- 6 files changed, 534 insertions(+), 10 deletions(-) create mode 100644 configs/sway/sway create mode 100644 configs/sway/waybar/config create mode 100644 configs/sway/waybar/style.css diff --git a/README.md b/README.md index 4367279..0d6390b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Features: - alacritty config (solarized dark, 60x20, JetBrains Mono) - Jetbrains Mono installation (macOS or Linux) - macOS-specific configuration ([Homebrew](https://brew.sh), git gpg fixing, alacritty and JetBrains Mono installation) - +- sway configs (sway + waybar) (fzf required) During the installation you can configure git by embedded configurator: - user.name diff --git a/configs/sway/sway b/configs/sway/sway new file mode 100644 index 0000000..9178b3d --- /dev/null +++ b/configs/sway/sway @@ -0,0 +1,101 @@ +set $mod Mod4 +set $left h +set $down j +set $up k +set $right l +set $term alacritty +for_window [app_id="^launcher$"] floating enable, sticky enable, resize set 30 ppt 60 ppt, border pixel 10 +set $menu exec $term --class=launcher -e $HOME/.dotfiles/utils/sway-launcher-desktop + +output * bg /usr/share/backgrounds/Iridescence-dark.png fill + +input * { + xkb_layout us,ru + xkb_options grp:alt_shift_toggle +} + +bar swaybar_command waybar +xwayland enable + +default_border pixel 5 +gaps inner 5 +gaps outer 5 + +font "JetBrains Mono" 13 + +exec swayidle -w \ + timeout 300 'swaylock -f -c 000000' \ + timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \ + before-sleep 'swaylock -f -c 000000' + +output * scale 2 + + bindsym $mod+Return exec $term + bindsym $mod+Shift+q kill + bindsym $mod+d exec $menu + floating_modifier $mod normal + bindsym $mod+Shift+c reload + bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit' + bindsym $mod+$left focus left + bindsym $mod+$down focus down + bindsym $mod+$up focus up + bindsym $mod+$right focus right + bindsym $mod+Left focus left + bindsym $mod+Down focus down + bindsym $mod+Up focus up + bindsym $mod+Right focus right + bindsym $mod+Shift+$left move left + bindsym $mod+Shift+$down move down + bindsym $mod+Shift+$up move up + bindsym $mod+Shift+$right move right + bindsym $mod+Shift+Left move left + bindsym $mod+Shift+Down move down + bindsym $mod+Shift+Up move up + bindsym $mod+Shift+Right move right + bindsym $mod+1 workspace number 1 + bindsym $mod+2 workspace number 2 + bindsym $mod+3 workspace number 3 + bindsym $mod+4 workspace number 4 + bindsym $mod+5 workspace number 5 + bindsym $mod+6 workspace number 6 + bindsym $mod+7 workspace number 7 + bindsym $mod+8 workspace number 8 + bindsym $mod+9 workspace number 9 + bindsym $mod+0 workspace number 10 + bindsym $mod+Shift+1 move container to workspace number 1 + bindsym $mod+Shift+2 move container to workspace number 2 + bindsym $mod+Shift+3 move container to workspace number 3 + bindsym $mod+Shift+4 move container to workspace number 4 + bindsym $mod+Shift+5 move container to workspace number 5 + bindsym $mod+Shift+6 move container to workspace number 6 + bindsym $mod+Shift+7 move container to workspace number 7 + bindsym $mod+Shift+8 move container to workspace number 8 + bindsym $mod+Shift+9 move container to workspace number 9 + bindsym $mod+Shift+0 move container to workspace number 10 + bindsym $mod+b splith + bindsym $mod+v splitv + bindsym $mod+s layout stacking + bindsym $mod+w layout tabbed + bindsym $mod+e layout toggle split + bindsym $mod+f fullscreen + bindsym $mod+Shift+space floating toggle + bindsym $mod+space focus mode_toggle + bindsym $mod+a focus parent + bindsym $mod+Shift+minus move scratchpad + bindsym $mod+minus scratchpad show +mode "resize" { + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + bindsym Left resize shrink width 10px + bindsym Down resize grow height 10px + bindsym Up resize shrink height 10px + bindsym Right resize grow width 10px + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +include /etc/sway/config.d/* + diff --git a/configs/sway/waybar/config b/configs/sway/waybar/config new file mode 100644 index 0000000..b9a5b46 --- /dev/null +++ b/configs/sway/waybar/config @@ -0,0 +1,162 @@ +{ + // "layer": "top", // Waybar at top layer + // "position": "bottom", // Waybar position (top|bottom|left|right) + "height": 30, // Waybar height (to be removed for auto height) + // "width": 1280, // Waybar width + "spacing": 0, // Gaps between modules (4px) + // Choose the order of the modules + "modules-left": ["sway/workspaces", "sway/mode"], + "modules-center": ["sway/window"], + "modules-right": ["idle_inhibitor", "network", "cpu", "memory", "keyboard-state", "sway/language", "clock", "tray"], + // Modules configuration + // "sway/workspaces": { + // "disable-scroll": true, + // "all-outputs": true, + // "format": "{name}: {icon}", + // "format-icons": { + // "1": "", + // "2": "", + // "3": "", + // "4": "", + // "5": "", + // "urgent": "", + // "focused": "", + // "default": "" + // } + // }, + "keyboard-state": { + "numlock": true, + "capslock": true, + "format": "{name} {icon}", + "format-icons": { + "locked": "", + "unlocked": "" + } + }, + "sway/mode": { + "format": "{}" + }, + "mpd": { + "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ", + "format-disconnected": "Disconnected ", + "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ", + "unknown-tag": "N/A", + "interval": 2, + "consume-icons": { + "on": " " + }, + "random-icons": { + "off": " ", + "on": " " + }, + "repeat-icons": { + "on": " " + }, + "single-icons": { + "on": "1 " + }, + "state-icons": { + "paused": "", + "playing": "" + }, + "tooltip-format": "MPD (connected)", + "tooltip-format-disconnected": "MPD (disconnected)" + }, + "idle_inhibitor": { + "format": "{icon}", + "format-icons": { + "activated": "", + "deactivated": "" + } + }, + "tray": { + // "icon-size": 21, + "spacing": 10 + }, + "clock": { + // "timezone": "America/New_York", + //"format": "{%h:%m:%s} {:%d.%m.%Y}", + "tooltip-format": "{:%Y %B}\n{calendar}", + //"format": "{%H:%M:%S} {%d.%m.%Y}", + "format-alt": "{:%d.%m.%Y}", + "interval": 1 + }, + "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 {icon}", + "format-icons": ["", "", ""] + }, + "backlight": { + // "device": "acpi_video1", + "format": "{percent}% {icon}", + "format-icons": ["", "", "", "", "", "", "", "", ""] + }, + "battery": { + "states": { + // "good": 95, + "warning": 30, + "critical": 15 + }, + "format": "{capacity}% {icon}", + "format-charging": "{capacity}% ", + "format-plugged": "{capacity}% ", + "format-alt": "{capacity}% {icon}", + // "format-good": "", // An empty format will hide the module + // "format-full": "", + "format-icons": ["", "", "", "", ""] + }, + "battery#bat2": { + "bat": "BAT2" + }, + "network": { + // "interface": "wlp2*", // (Optional) To force the use of this interface + "format-wifi": "", + "format-ethernet": "", + "tooltip-format": "{ifname} via {essid} {gwaddr}/{cidr} ", + "format-linked": "{ifname} (No IP) ", + "format-disconnected": "Disconnected ⚠", + // "format-alt": "{ifname} ({essid}): {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": ["", "", ""] + }, + "on-click": "pavucontrol" + }, + "custom/media": { + "format": "{icon} {}", + "return-type": "json", + "max-length": 40, + "format-icons": { + "spotify": "", + "default": "🎜" + }, + "escape": true, + "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder + // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name + } +} + diff --git a/configs/sway/waybar/style.css b/configs/sway/waybar/style.css new file mode 100644 index 0000000..c1284f0 --- /dev/null +++ b/configs/sway/waybar/style.css @@ -0,0 +1,255 @@ +* { + /* `otf-font-awesome` is required to be installed for icons */ + font-family: JetBrains Mono, FontAwesome, Roboto, Helvetica, Arial, sans-serif; + font-size: 13px; +} + +window#waybar { + background-color: rgba(43, 48, 59, 0.5); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + transition-property: background-color; + transition-duration: .5s; +} + +window#waybar.hidden { + opacity: 0.5; +} + +/* +window#waybar.empty { + background-color: transparent; +} +window#waybar.solo { + background-color: #FFFFFF; +} +*/ + +window#waybar.termite { + background-color: #3F3F3F; +} + +window#waybar.chromium { + background-color: #000000; + border: none; +} + +#workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each workspace name */ + border: none; + border-radius: 0; +} + +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +#workspaces button:hover { + background: rgba(0, 0, 0, 0.2); + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.focused { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.urgent { + background-color: #eb4d4b; +} + +#mode { + background-color: #64727D; + border-bottom: 3px solid #ffffff; +} + +#clock, +#battery, +#cpu, +#memory, +#disk, +#temperature, +#backlight, +#network, +#pulseaudio, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#mpd { + padding: 0 10px; + color: #ffffff; +} + +#window, +#workspaces { + margin: 0 4px; +} + +/* If workspaces is the leftmost module, omit left margin */ +.modules-left > widget:first-child > #workspaces { + margin-left: 0; +} + +/* If workspaces is the rightmost module, omit right margin */ +.modules-right > widget:last-child > #workspaces { + margin-right: 0; +}/* + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: #000000; +}*/ + +/*#battery.charging, #battery.plugged { + color: #ffffff; + background-color: #26A65B; +}*/ + +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} + +#battery.critical:not(.charging) { +/* background-color: #f53c3c; + color: #ffffff; + animation-name: blink;*/ + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +label:focus { + background-color: #000000; +} + +/*#cpu { + background-color: #2ecc71; + color: #000000; +} + +#memory { + background-color: #9b59b6; +} + +#disk { + background-color: #964B00; +} + +#backlight { + background-color: #90b1b1; +} + +#network { + background-color: #2980b9; +} + +#network.disconnected { + background-color: #f53c3c; +} + +#pulseaudio { + background-color: #f1c40f; + color: #000000; +} + +#pulseaudio.muted { + background-color: #90b1b1; + color: #2a5c45; +} + +#custom-media { + background-color: #66cc99; + color: #2a5c45; + min-width: 100px; +} + +#custom-media.custom-spotify { + background-color: #66cc99; +} + +#custom-media.custom-vlc { + background-color: #ffa000; +} + +#temperature { + background-color: #f0932b; +} + +#temperature.critical { + background-color: #eb4d4b; +} + +#tray { + background-color: #2980b9; +} + +#tray > .passive { + -gtk-icon-effect: dim; +} + +#tray > .needs-attention { + -gtk-icon-effect: highlight; + background-color: #eb4d4b; +} + +#idle_inhibitor { + background-color: #2d3436; +} + +#idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; +} + +#mpd { + background-color: #66cc99; + color: #2a5c45; +} + +#mpd.disconnected { + background-color: #f53c3c; +} + +#mpd.stopped { + background-color: #90b1b1; +} + +#mpd.paused { + background-color: #51a37a; +} +*/ +#language { + /*background: #00b093; + color: #740864;*/ + padding: 0 5px; + margin: 0 0px; + min-width: 16px; +} + +#keyboard-state { + background: #97e1ad; + color: #000000; + padding: 0 0px; + margin: 0 5px; + min-width: 16px; +} +/* +#keyboard-state > label { + padding: 0 5px; +} + +#keyboard-state > label.locked { + background: rgba(0, 0, 0, 0.2); +} +*/ diff --git a/tools/install.sh b/tools/install.sh index 5a42ee6..f3ea01f 100644 --- a/tools/install.sh +++ b/tools/install.sh @@ -32,6 +32,11 @@ then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/JetBrains/JetBrainsMono/master/install_manual.sh)" fi +# installing sway-launcher + +curl https://raw.githubusercontent.com/Biont/sway-launcher-desktop/master/sway-launcher-desktop.sh > $HOME.dotfiles/utils/sway-launcher-desktop +chmod +x $HOME.dotfiles/utils/sway-launcher-desktop + # linking dotfiles to their original locations echo "${GREEN}Linking dotfiles$CLEAR_COLOR" @@ -53,4 +58,4 @@ fi chmod +x $HOME/.dotfiles/tools/* -exec zsh \ No newline at end of file +exec zsh diff --git a/tools/relink.sh b/tools/relink.sh index 3f88be7..37ccd6f 100644 --- a/tools/relink.sh +++ b/tools/relink.sh @@ -3,14 +3,15 @@ # script that (re)links all dotfiles during the installation or upgrade. # do not run manually -GREEN="\033[32m" -CLEAR_COLOR="\033[0m" - -mkdir -p $HOME/.config/nvim $HOME/.config/alacritty >/dev/null 2>&1 -rm $HOME/.zshrc $HOME/.config/nvim/init.vim $HOME/.config/alacritty/alacritty.yml >/dev/null 2>&1 +mkdir -p $HOME/.config/nvim $HOME/.config/alacritty $HOME/.config/sway $HOME/.config/waybar >/dev/null 2>&1 +rm -rf $HOME/.zshrc $HOME/.config/nvim/init.vim $HOME/.config/alacritty/alacritty.yml $HOME/.config/sway/* $HOME/.config/waybar/* >/dev/null 2>&1 ln -s $HOME/.dotfiles/configs/zshrc $HOME/.zshrc -echo "${GREEN}.zshrc linked: $CLEAR_COLOR$HOME/.dotfiles/configs/zshrc $GREEN-> $CLEAR_COLOR$HOME/.zshrc" +echo ".zshrc linked: $HOME/.dotfiles/configs/zshrc -> $HOME/.zshrc" ln -s $HOME/.dotfiles/configs/nvim.vim $HOME/.config/nvim/init.vim -echo "${GREEN}neovim config linked: $CLEAR_COLOR$HOME/.dotfiles/configs/nvim.vim $GREEN-> $CLEAR_COLOR$HOME/.config/nvim/init.vim" +echo "neovim config linked: $HOME/.dotfiles/configs/nvim.vim -> $HOME/.config/nvim/init.vim" ln -s $HOME/.dotfiles/configs/alacritty.yml $HOME/.config/alacritty/alacritty.yml -echo "${GREEN}alacritty config linked: $CLEAR_COLOR$HOME/.dotfiles/configs/alacritty.yml $GREEN-> $CLEAR_COLOR$HOME/.config/alacritty/alacritty.yml" +echo "alacritty config linked: $HOME/.dotfiles/configs/alacritty.yml -> $HOME/.config/alacritty/alacritty.yml" +ln -s $HOME/.dotfiles/configs/sway/sway $HOME/.config/sway/config +ln -s $HOME/.dotfiles/configs/sway/waybar/config $HOME/.config/waybar/config +ln -s $HOME/.dotfiles/configs/sway/waybar/style.css $HOME/.config/waybar/style.css +echo "sway and waybar configs linked"