From c4b69bf43ed48ee386e527134cb1c2e9c214bd4b Mon Sep 17 00:00:00 2001 From: OdiousImp2604 <74424076+OdiousImp2604@users.noreply.github.com> Date: Sun, 24 Jan 2021 13:47:49 +0000 Subject: [PATCH] Waybar and Wodi --- .config/waybar/config | 65 +++--- .config/waybar/config2 | 244 ++++++++++++++++++++ .config/waybar/modules/spotify.sh | 18 ++ .config/waybar/modules/update-check.go | 58 +++++ .config/waybar/modules/update-system.sh | 3 + .config/waybar/modules/weather.sh | 3 + .config/waybar/scripts/mediaplayer.sh | 3 + .config/waybar/scripts/power-menu.sh | 2 +- .config/waybar/scripts/power.sh | 7 + .config/waybar/style.css | 86 ++++--- .config/waybar/style2.css | 285 ++++++++++++++++++++++++ .config/waybar/taskbar | 5 + .config/wofi/config | 2 +- .config/wofi/style.css | 73 +++--- .config/wofi/window.sh | 6 + .config/wofi/windows.py | 100 +++++++++ 16 files changed, 845 insertions(+), 115 deletions(-) create mode 100644 .config/waybar/config2 create mode 100644 .config/waybar/modules/spotify.sh create mode 100644 .config/waybar/modules/update-check.go create mode 100644 .config/waybar/modules/update-system.sh create mode 100644 .config/waybar/modules/weather.sh create mode 100644 .config/waybar/scripts/mediaplayer.sh create mode 100644 .config/waybar/scripts/power.sh create mode 100644 .config/waybar/style2.css create mode 100644 .config/waybar/taskbar create mode 100644 .config/wofi/window.sh create mode 100644 .config/wofi/windows.py diff --git a/.config/waybar/config b/.config/waybar/config index c4023c0..38b1532 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -15,10 +15,7 @@ ], "modules-right": [ - "custom/firefox", - "custom/files", - "custom/terminal", - "network", + "network", "memory", "cpu", // "custom/weather", @@ -33,23 +30,6 @@ // Modules -"sway/workspaces": { - "disable-scroll": true, - "all-outputs": false, - "format": "{icon}", - "format-icons": { - "1": "", - "2": "", - "3": "", - "4": "", - "5": "", - "6": "", - "urgent": "", - "focused": ",", - "default": "" - } -}, - "battery": { "states": { // "good": 95, @@ -121,28 +101,26 @@ }, "sway/workspaces": { - "all-outputs": false, - "disable-scroll": true, - "format": "{icon} {name}", - "format-icons": { - "1:www": "", // Icon: firefox-browser - "2:mail": "", // Icon: mail - "3:editor": "", // Icon: code - "4:terminals": "", // Icon: terminal - "5:portal": "", // Icon: terminal - "urgent": "", - "focused": "", - "default": "" - } -}, - + "disable-scroll": true, + "disable-markup" : false, + "all-outputs": true, + "format": " {icon} ", + //"format":"{icon}", + "format-icons": { + "1": "", + "2": "", + "3": "", + "4": "", + "5": "", + } + }, "pulseaudio": { "scroll-step": 1, // %, can be a float "format": "{volume}% {icon}", "format-bluetooth": "{volume}% {icon}  {format_source}", "format-bluetooth-muted": " {icon}  {format_source}", - "format-muted": " {format_source}", - "format-source": "{volume}% ", + "format-muted": "婢 {format_source}", + "format-source": "{volume}% ", "format-source-muted": "", "format-icons": { "headphone": "", @@ -151,7 +129,7 @@ "phone": "", "portable": "", "car": "", - "default": ["奄"] + "default": [""] }, "on-click": "pavucontrol", "on-scroll-up": "pamixer -ui 2", @@ -167,6 +145,7 @@ "tray": { "icon-size": 18, + "spacing":10, }, "backlight": { @@ -209,3 +188,11 @@ "tooltip": false, }, } +"wlr/taskbar": { + "format": "{icon}", + "icon-size": 14, + "icon-theme": "Numix-Circle", + "tooltip-format": "{title}", + "on-click": "activate", + "on-click-middle": "close" +} diff --git a/.config/waybar/config2 b/.config/waybar/config2 new file mode 100644 index 0000000..0cd6edc --- /dev/null +++ b/.config/waybar/config2 @@ -0,0 +1,244 @@ +[{ + "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": 2560, // Waybar width + // Choose the order of the modules + + "margin-right": 8, + "margin-left": 8, + "margin-top": 1, + "margin-bottom":8, + + "modules-left": ["custom/launcher", "sway/workspaces","custom/firefox", "custom/libreoffice", "custom/youtube", "custom/dolphin", "custom/kate","custom/store", "custom/spotify",], + "modules-center": ["sway/window",], + "modules-right": ["pulseaudio", "custom/weather", "cpu", "custom/pacman", "battery", "backlight" , "tray", "clock", "custom/recorder", "custom/power", ], + // Modules configuration + "sway/workspaces": { + "disable-scroll": false, + "all-outputs": true, + "format": "{icon}", + "persistent_workspaces": { + "1": [], + "2": [], + "3": [], + "4": [], + }, + "format-icons": { + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "focused": "", + "urgent": "", + "default": "" + }, + "icon-size": 15 + }, + "river/tags": { + "num-tags": 5 + }, + "sway/mode": { + "format": "{}" + }, + "sway/window": { + "format": "{}", + "max-length": 65, + }, + "custom/media": { + "format": "{icon}{}", + "return-type": "json", + "format-icons": { + "Playing": " ", + "Paused": " ", + "Music": " " + }, + "max-length":65, + "interval": 2, + "exec": "fish -c playerstatus", + "exec-on-event": "fish -c playerstatus", + "on-click": "playerctl play-pause", + "on-click-right": "mpc toggle --host 127.0.0.1 --port 6002", + }, + "custom/recorder": { + "return-type": "json", + "format": "", + "interval": 1, + "exec-if": "pgrep wf-recorder", + "exec": "echo '{\"class\": \"recording\"}'", + "on-click": "fish -c recording", + "tooltip": false, + }, + "tray": { + "spacing": 10, + }, + "idle_inhibitor": { + "format": "{icon}", + "format-icons": { + "activated": "", + "deactivated": "" + } + }, + "clock": { + + // "timezone": "America/New_York", + "format": "{:%I:%M %p}", + "format-alt": "{:%A, %B %d}", + "tooltip-format": "{:%Y %B}\n{calendar}", + // "format-alt": "{:%Y-%m-%d}" + }, + "cpu": { + "format": "{usage} ", + "on-click": "alacritty -e ytop", + "tooltip": false + }, + "memory": { + "format": "{} " + }, + "temperature": { + "thermal-zone": 2, + "hwmon-path": "/sys/class/hwmon/hwmon0/temp1_input", + "critical-threshold": 80, + "format-critical": "{temperatureC}°C {icon}", + "format": "{temperatureC} {icon}", + "interval": 60, + "format-icons": ["", "", ""] + }, + "backlight": { + "interval": 5, + "format": "{icon}", + "format-alt": "{percent}% {icon}", + "format-alt-click": "click-right", + "format-icons": ["🌕", "🌔", "🌓", "🌒", "🌑"], + "on-scroll-down": "brightnessctl -c backlight set +5%", + "on-scroll-up": "brightnessctl -c backlight set 5%-" + }, + "battery": { + "states": { + // "good": 95, + "warning": 30, + "critical": 15 + }, + "format": "{capacity}% {icon}", + "format-charging": "{capacity}% ", + "format-plugged": "{capacity}% ", + "format-alt": "{time} {icon}", + // "format-good": "", // An empty format will hide the module + // "format-full": "", + "format-icons": ["", "", "", "", ""] + }, + "battery#bat2": { + "bat": "BAT2" + }, + "network": { + "interface": "wlan0", // (Optional) To force the use of this interface + "format-wifi": " connected", + "format-ethernet": "{ifname}: {ipaddr}/{cidr} ", + "format-linked": "{ifname} (No IP) ", + "format-disconnected": "Disconnected ⚠", + "format-alt": "{ifname}: {ipaddr}/{cidr}", + "interval": 60, + "on-click-right": "exec /home/aryan/nmcli-rofi/nmcli-rofi" + }, + "pulseaudio": { + "scroll-step": 1, // %, can be a float + "format": "{volume}% {icon}", + "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", + "on-scroll-up": "pactl set-sink-volume @DEFAULT_SINK@ -5%", + "on-scroll-down": "pactl set-sink-volume @DEFAULT_SINK@ +5%", + }, + "custom/weather": { + "exec": "~/.config/waybar/scripts/weather.sh Royal Tunbridge Wells", + "format": "{}", + "return-type": "json", + "interval": 600 + }, + "custom/pacman": { + "format": "{} ", + "interval": 3600, // every hour + // "restart-interval": 3600, + "exec": "checkupdates | wc -l", // # of updates + "exec-if": "exit 0", // always run; consider advanced run conditions + "on-click": "alacritty -e yay; pkill -SIGRTMIN+8 waybar", // update system + "signal": 8, + }, + "disk": { + "interval": 30, + "format": "{free}", + "path": "/run/media/aryan/", + }, + "custom/power": { + "format": "⏻", + "on-click": "exec nwgbar", + "tooltip": false + }, + "custom/firefox": { + "format": "", + "on-click": "exec firefox", + "tooltip": false + }, + "custom/libreoffice": { + "format": "", + "on-click": "exec libreoffice", + "tooltip": false + }, + "custom/youtube": { + "format": "輸", + "on-click": "xdg-open https://www.youtube.com/", + "tooltip": false + }, + "custom/dolphin": { + "format": "", + "on-click": "exec dolphin", + "tooltip": false + }, + "custom/kate": { + "format": "", + "on-click": "exec kate", + "tooltip": false + }, + "custom/store": { + "format": " ", + "on-click": "exec pamac-manager", + "tooltip": false + }, + "custom/launcher": { + "format":" ", + "on-click": "exec ~/.config/rofi/launchers/text/launcher.sh", + "tooltip": false + }, + + "wlr/taskbar": { + "format": "{icon}", + // "format": "{app_id}", + "icon-theme": "Papirus", + "icon-size": 15, + "on-click": "activate", + "markup": true, + "max-length": 7, + "on-click-right": "minimize", + "on-click-middle": "close" + }, + "custom/spotify": { + "interval": 1, + "return-type": "json", + "exec": "~/.config/waybar/modules/spotify.sh", + "exec-if": "pgrep spotify", + "escape": true + } +}] diff --git a/.config/waybar/modules/spotify.sh b/.config/waybar/modules/spotify.sh new file mode 100644 index 0000000..c00622b --- /dev/null +++ b/.config/waybar/modules/spotify.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +class=$(playerctl metadata --player=spotify --format '{{lc(status)}}') +icon="" + +if [[ $class == "playing" ]]; then + info=$(playerctl metadata --player=spotify --format '{{artist}} - {{title}}') + if [[ ${#info} > 40 ]]; then + info=$(echo $info | cut -c1-40)"..." + fi + text=$info" "$icon +elif [[ $class == "paused" ]]; then + text=$icon +elif [[ $class == "stopped" ]]; then + text="" +fi + +echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}" diff --git a/.config/waybar/modules/update-check.go b/.config/waybar/modules/update-check.go new file mode 100644 index 0000000..e329402 --- /dev/null +++ b/.config/waybar/modules/update-check.go @@ -0,0 +1,58 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "os/exec" + "strings" +) + +type jsonOutput struct { + Text string `json:"text,omitempty"` + Alt string `json:"alt,omitempty"` + Tooltip string `json:"tooltip,omitempty"` + Class string `json:"class,omitempty"` + Percentage int `json:"percentage,omitempty"` +} + +func main() { + o := jsonOutput{} + + pac, err := exec.Command("checkupdates").CombinedOutput() + if err != nil { + o.Tooltip = err.Error() + } + + aur, err := exec.Command("yay", "--devel", "-Qu").CombinedOutput() + if err != nil { + o.Tooltip += err.Error() + } + + updates := append(strings.Split(string(pac), "\n"), strings.Split(string(aur), "\n")...) + updates = removeEmptyLines(updates) + + n := len(updates) + + o.Class = "no-updates" + if n > 0 { + o.Class = "updates" + o.Tooltip = strings.Join(updates, "\n") + } + + o.Text = fmt.Sprintf("%d", n) + o.Alt = fmt.Sprintf("%d", n) + o.Percentage = n + + json.NewEncoder(os.Stdout).Encode(o) +} + +func removeEmptyLines(list []string) []string { + out := []string{} + for _, line := range list { + if len(line) > 0 { + out = append(out, line) + } + } + return out +} diff --git a/.config/waybar/modules/update-system.sh b/.config/waybar/modules/update-system.sh new file mode 100644 index 0000000..af30cdb --- /dev/null +++ b/.config/waybar/modules/update-system.sh @@ -0,0 +1,3 @@ +#!/bin/bash +alacritty --class aptus-upgrade -e yay --devel -Syu + diff --git a/.config/waybar/modules/weather.sh b/.config/waybar/modules/weather.sh new file mode 100644 index 0000000..b9e6668 --- /dev/null +++ b/.config/waybar/modules/weather.sh @@ -0,0 +1,3 @@ +#!/bin/bash +report=$(curl wttr.in/?format="%C,+%t") +echo $report diff --git a/.config/waybar/scripts/mediaplayer.sh b/.config/waybar/scripts/mediaplayer.sh new file mode 100644 index 0000000..b8e86dc --- /dev/null +++ b/.config/waybar/scripts/mediaplayer.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo '{"text": "'$(playerctl metadata title)'", "alt": "'$(playerctl status)'", "tooltip": "'$(playerctl metadata --format "{{ playerName }} : {{ artist }} - {{ title }}")'", "class": "'$(playerctl status)'" }' diff --git a/.config/waybar/scripts/power-menu.sh b/.config/waybar/scripts/power-menu.sh index 57a97de..5a35001 100644 --- a/.config/waybar/scripts/power-menu.sh +++ b/.config/waybar/scripts/power-menu.sh @@ -2,7 +2,7 @@ entries="Logout Suspend Reboot Shutdown" -selected=$(printf '%s\n' $entries | wofi --width 300 --height 150 --show=dmenu --cache-file /dev/null | awk '{print tolower($1)}') +selected=$(printf '%s\n' $entries | wofi --width 100 --height 20 --show=dmenu --cache-file /dev/null | awk '{print tolower($1)}') case $selected in logout) diff --git a/.config/waybar/scripts/power.sh b/.config/waybar/scripts/power.sh new file mode 100644 index 0000000..9c77bd8 --- /dev/null +++ b/.config/waybar/scripts/power.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if pgrep river; then + wlogout -p layer-shell +else + nwgbar -o 0.4 +fi diff --git a/.config/waybar/style.css b/.config/waybar/style.css index 14002ce..ae206b5 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -9,6 +9,14 @@ /* ----------------------------------------------------------------------------- * Keyframes * -------------------------------------------------------------------------- */ + /* +Arc-Dark Color Scheme +*/ + +@define-color highlight #5294e2 ; +@define-color base1 #404552 ; + + @keyframes blink-warning { 70% { @@ -39,22 +47,39 @@ /* Reset all styles */ * { - border: none; + border: none; border-radius: 0; - margin-top: 0px; - padding-top: 1px; - padding-bottom: 1px; - padding-left: 10; - padding-right: 10; + min-height: 0; + margin: 1px; + padding: 1.5; } - + /* The whole bar */ #waybar { - background: black; - color: white; + background: transparent; + color: #bebebe; + background-color: @base1; font-family: UbuntuMono; font-size: 14px; } + +/* Each module */ +#battery, +#clock, +#backlight, +#cpu, +#custom-keyboard-layout, +#memory, +#mode, +#network, +#pulseaudio, +#temperature, +#tray { + margin-left:10px; + margin-right:10px; +} + + /* ----------------------------------------------------------------------------- @@ -112,7 +137,7 @@ #mode { background: red; border-bottom: 3px transparent; - margin: 3; + margin: 3px; } #network.disconnected { @@ -120,7 +145,7 @@ } #pulseaudio.muted { - color: @base07; + color: @highlight; } #temperature.critical { @@ -132,15 +157,16 @@ } #workspaces button { - border-bottom: 3px solid transparent; - margin-bottom: 0; - padding-left: 1; - padding-right:1; + border-bottom: 3px solid transparent; + margin-bottom: 0px; + padding:0px; } #workspaces button.focused { - border-bottom: 3px solid #ffffff; + border-bottom: 3px solid @highlight; + margin-bottom: 1px; + padding-left:0; } #workspaces button.urgent { @@ -148,22 +174,14 @@ color: #c9545d; } -#custom-firefox { - color: #d08770; -} -#custom-files { - color: #ebcb8b; -} - -#custom-power { - font-size: 15px; - margin-right:1px; - padding:0; -} - -#custom-launcher { - font-size: 20px; - padding:0; - } +#custom-power, +#custom-launcher{ + margin-left:15px; + margin-right:15px; + font-size:15px; +} +#custom-launcher{ + font-size:20px; + } + - diff --git a/.config/waybar/style2.css b/.config/waybar/style2.css new file mode 100644 index 0000000..f076a4f --- /dev/null +++ b/.config/waybar/style2.css @@ -0,0 +1,285 @@ + +* { + border: none; + font-size: 15px; + margin: 2.5px; + font-family: MagicMushroom; + + +} +window#waybar { + background-color: transparent; + color: #d8dee9; + border-radius: 15px; +} +#workspaces { + font-family:JetBrainsMono; + background-color: #3b4252; + padding: 1px 5px 1px 5px; + font-size: 15px; + border-radius: 10px; +} +#workspaces button { + font-size: 10px; + border-radius: 10px; + margin: 0; + background-color: transparent; + color: #ffffff; +} +#window { + color: #d8dee9; + margin: 0px; + font-size: 14px; + border-radius: 10px; + padding: 0px 6px 0px 6px; +} +@keyframes fadeIn { + from {opacity: 0;} + to {opacity: 1;} +} +window#waybar.empty { + /* background-color: #353b49; */ +} +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +#workspaces button:hover { + box-shadow: inherit; + color: #5e81ac; +} +#workspaces button.focused,#tags button.occupied { + color: #81a1c1; +} +#tags button.focused { + color: #5e81ac; +} +#workspaces button.urgent { + color: #BF616A; +} +#tags button { + font-family:MagicMushroom; + font-weight: 600; +} +#mpd { + padding: 0px 10px; + color: #ffffff; +} +/* TASKBAR */ +#taskbar { + margin: 2px 4px 2px 4px; +} +#taskbar button { + border-radius: 10px; + font-size: 14px; + margin: 0px 5px 0px 5px; + padding: 0px 6px 0px 6px; + background-color: #2e3440; +} +#taskbar button.active { + /* background-color: #434c5e; */ + color: #5e81ac; +} +#taskbar button.minimized { + color: #ebcb8b; +} +#taskbar button:hover { + box-shadow: inherit; + background-color: rgba(35,39,49,0.4); +} +/* BROWSER BOOKMARKS */ +#custom-name, #custom-firefox,#custom-libreoffice,#custom-dolphin,#custom-youtube,#custom-kate, #custom-store. { + background-color: transparent; + font-size: 15px; + margin-left: 0; + margin-right: 0; + padding: 0px 15px 0px 15px ; +} +#custom-firefox { + margin-left: 10px; + border-radius: 10px 0px 0px 10px; + font-size: 15px; + color: #d08770; +} +#custom-libreoffice { + color: #ebcb8b; + font-size: 15px; +} +#custom-library { + color: #c57078; + font-size: 15px; +} +#custom-dolphin { + color: #a3be8c; + border-radius: 0px 10px 10px 0px; + font-size: 15px; +} +#custom-youtube { + color: #b48ead; + font-size: 15px; +} +#custom-kate { + color: #88c0d0; + font-size: 15px; +} +#custom-store { + margin-left: 10px; + font-size: 15px; +} +#custom-launcher { + margin-left: 10px; + margin-right: 10px; + font-size: 15px; + background-color: #88c0d0; + padding: 7px 7px 7px 7px; + border-radius: 15px; +} + +/* WIDGETS */ +#cpu, #idle_inhibitor, #custom-pacman, #memory, #backlight, #disk, #network, #pulseaudio, #custom-weather, #temperature, #mpd { + font-size: 14px; + background-color: #3b4252; + padding: 0px 14px 0px 14px; + margin: 3px 0px 3px 0px; + border-radius: 0px; +} +#disk { + color:#b48ead; +} +#memory { + color:#d08770; +} +#cpu { + color:#c57078; +} +#network { + color: #9da98d; +} +#custom-weather { + color:#81a1c1; +} +#custom-weather { + padding: 0px 8px 0px 8px; + background-color:#4c566a; + color:#b48ead; +} +#custom-media { + color: #818896; + border-radius: 0px; + margin-left: 10px; + padding: 0px 14px 0px 14px; +} +#custom-media.Playing { + color: #81a1c1; + border-radius: 0px; + font-weight: 500; +} +#custom-media.Music { + color: #b48ead; + border-radius: 0px; + font-weight: 500; +} +#custom-pacman { + color: #ebcb8b; + border-radius: 0px 10px 10px 0px; + font-weight: 600; + background-color:#4c566a; +} +#pulseaudio { + color: #8fbcbb; + border-radius: 10px 0px 0px 10px; +} +#pulseaudio.muted { + border-radius: 10px; + color: #4c566a; +} +#temperature{ + color: #88c0d0; +} +#temperature.critical { + color: #eb4d4b; +} +#backlight{ + background-color:#4c566a; + margin: 3px 0px 3px 0px; + color: #ebcb8b; + border-radius: 0px 10px 10px 0px; + font-size: 17px; + +} +#battery { + font-size: 14px; + background-color: #3b4252; + border-radius: 10px 0px 0px 10px; + color: #88c0d0; + padding: 0px 14px 0px 14px; + margin: 3px 0px 3px 12px; +} +#battery.charging { + color: #ffffff; +} +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} +#battery.critical:not(.charging) { + background-color: #88c0d0; + border-radius: 10px; + 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; + +} +#idle_inhibitor { + font-size: 20px; + color: #6f7787; +} +#idle_inhibitor.activated { + color: #ffffff; +} + #custom-power, #custom-recorder, #tray { + background-color: transparent; + padding: 2px 10px 2px 10px; + margin: 2px 10px 2px 10px; +} +#clock { + font-family:MagicMushroom; + font-size: 14px; + margin-left: 5px; + padding: 0px 14px 0px 14px; + background-color: #3b4252; + border-radius: 10px; +} +#custom-recorder { + color:#c57078; + padding: 2px 5px 2px 15px; + margin: 2px 2px 2px 2px; + font-size: 18px; +} +#tray { + border-radius: 15px; + margin-left: 7px; + color: #8fbcbb; +} +#custom-power { + color: #eceff4; + background-color: #88c0d0; + font-size: 17px; + margin-right: 2px; + border-radius: 15px; +} +#mpd.disconnected { + background-color: #f53c3c; +} +#mpd.stopped { + background-color: #90b1b1; +} +#mpd.paused { + background-color: #51a37a; +} + diff --git a/.config/waybar/taskbar b/.config/waybar/taskbar new file mode 100644 index 0000000..c979098 --- /dev/null +++ b/.config/waybar/taskbar @@ -0,0 +1,5 @@ +{ + "layer": "top", + "position": "bottom", + "height": 25 +} diff --git a/.config/wofi/config b/.config/wofi/config index 137afb8..7c949bf 100644 --- a/.config/wofi/config +++ b/.config/wofi/config @@ -1,4 +1,4 @@ - +hide_search=false hide_scroll=true show=drun,run width=700 diff --git a/.config/wofi/style.css b/.config/wofi/style.css index aa66c67..dbd6a90 100644 --- a/.config/wofi/style.css +++ b/.config/wofi/style.css @@ -1,59 +1,52 @@ -#entry { -border-radius: 5px; -padding: 3px; -margin: 0px 3px 3px 3px; +/* +Arc-Dark Color Scheme +*/ + +@define-color highlight #5294e2; +@define-color base1 #404552; +@define-color base2 #40455; + + +*{ + font-family: UbuntuMono; } -@keyframes fadeIn { - from {opacity: 0;} - to {opacity: 1;} -} - -#entry:selected { -background-color:#4b3766; -font-weight: bold; -} - -#text:selected { -color: #d8dee9; -} - -#window { -background-color: transparent; -font-family: Ubuntu Mono; +window { } #input { -border: none; -background-color: #4c566a; -padding: 10px; -margin: 15px 15px 10px 15px; -border-radius: 5px; + margin-bottom: 10px; + border-radius: 3px; + border:none; + color: white; } #inner-box { -color: #4b3766; -padding-top: 5px; -margin: 0px 10px 10px 10px; + background-color: @base2; + } #outer-box { -margin: 15px; -background-color: rgba(53,59,73,1.0); -box-shadow: 0px 0px 5px 0 #0F0F0F; + margin: 3px; + padding:15px; + background-color: @base2; } #scroll { -margin-bottom: 10px; } #text { padding: 5px; -color: #d8dee9; -background-color: transparent; -} - -#img { - background-color: transparent; - padding: 5px; +color: white; +} + +#entry:nth-child(even){ + background-color: @base1; +} + +#entry:selected { + background-color: @highlight; +} + +#text:selected { } diff --git a/.config/wofi/window.sh b/.config/wofi/window.sh new file mode 100644 index 0000000..7062117 --- /dev/null +++ b/.config/wofi/window.sh @@ -0,0 +1,6 @@ +swaymsg -t get_tree | + jq -r '.nodes[].nodes[] | if .nodes then [recurse(.nodes[])] else [] end + .floating_nodes | .[] | select(.nodes==[]) | ((.id | tostring) + "" + .name)' | + wofi -c ~/.config/wofi/menu -s ~/.config/wofi/sway.css --show dmenu | { + read -r id name + swaymsg "[con_id=$id]" focused +} diff --git a/.config/wofi/windows.py b/.config/wofi/windows.py new file mode 100644 index 0000000..7da060f --- /dev/null +++ b/.config/wofi/windows.py @@ -0,0 +1,100 @@ +#!/bin/python3 +from argparse import ArgumentParser +import subprocess +import json + +enter="\n" + +# Returns a list of all json window objects +def get_windows(): + + command="swaymsg -t get_tree" + + active_outputs = [] + + process = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) + data = json.loads(process.communicate()[0]) + + # Select outputs that are active + windows = [] + for output in data['nodes']: + + # The scratchpad (under __i3) is not supported + if output.get('name') != '__i3' and output.get('type') == 'output': + workspaces = output.get('nodes') + for ws in workspaces: + if ws.get('type') == 'workspace': + windows += extract_nodes_iterative(ws) + return windows + +# Extracts all windows from a sway workspace json object +def extract_nodes_iterative(workspace): + all_nodes = [] + + floating_nodes = workspace.get('floating_nodes') + + for floating_node in floating_nodes: + all_nodes.append(floating_node) + + nodes = workspace.get('nodes') + + for node in nodes: + + # Leaf node + if len(node.get('nodes')) == 0: + all_nodes.append(node) + # Nested node, handled iterative + else: + for inner_node in node.get('nodes'): + nodes.append(inner_node) + + return all_nodes + +# Returns an array of all windows +def parse_windows(windows): + parsed_windows = [] + for window in windows: + parsed_windows.append(window.get('name')) + return parsed_windows + +# Returns a newline seperated UFT-8 encoded string of all windows for wofi +def build_wofi_string(windows): + return enter.join(windows).encode("UTF-8") + +# Executes wofi with the given input string +def show_wofi(windows): + + command="wofi -c ~/.config/wofi/menu -s ~/.config/wofi/sway.css -p \"Windows: \" -d -i --hide-scroll" + + process = subprocess.Popen(command,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE) + return process.communicate(input=windows)[0] + +# Returns the sway window id of the window that was selected by the user inside wofi +def parse_id(windows, parsed_windows, selected): + selected = (selected.decode("UTF-8"))[:-1] # Remove new line character + window_index = int(parsed_windows.index(selected)) # Get index of selected window in the parsed window array + return str(windows[window_index].get('id')) # Get sway window id based on the index + +# Switches the focus to the given id +def switch_window(id): + command="swaymsg [con_id={}] focus".format(id) + + process = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) + process.communicate()[0] + +# Entry point +if __name__ == "__main__": + + parser = ArgumentParser(description="Wofi based window switcher") + + windows = get_windows() + + parsed_windows = parse_windows(windows) + + wofi_string = build_wofi_string(parsed_windows) + + selected = show_wofi(wofi_string) + + selected_id = parse_id(windows, parsed_windows, selected) + + switch_window(selected_id)