From 3ab7c6aad702c43de650a2851fd0e212caae2fcd Mon Sep 17 00:00:00 2001 From: theanonymousexyz Date: Sat, 16 Apr 2022 18:51:22 +0200 Subject: [PATCH] Add custom linux-hardened deny_new_usb module --- waybar/.config/waybar/config | 8 +++++++- waybar/.config/waybar/style.css | 20 +++++++++++++++++--- waybar/.config/waybar/usb-status.sh | 13 +++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100755 waybar/.config/waybar/usb-status.sh diff --git a/waybar/.config/waybar/config b/waybar/.config/waybar/config index d736ac1..7cf8eda 100644 --- a/waybar/.config/waybar/config +++ b/waybar/.config/waybar/config @@ -4,7 +4,7 @@ "height": 36, // Waybar height (to be removed for auto height) // "width": 1280, // Waybar width // Choose the order of the modules - "modules-left": ["idle_inhibitor", "sway/workspaces", "sway/mode"], + "modules-left": ["idle_inhibitor", "sway/workspaces", "custom/usb", "sway/mode"], "modules-center": ["clock"], "modules-right": ["custom/ivpn", "network", "pulseaudio", "backlight", "cpu", "memory", "battery", "tray"], // Modules configuration @@ -113,5 +113,11 @@ "return-type": "json", "interval": 1, "on-click": "$HOME/.config/waybar/ivpn-reconnect.sh" + }, + "custom/usb": { + "format": "{} USB", + "exec": "$HOME/.config/waybar/usb-status.sh", + "return-type": "json", + "interval": 1, } } diff --git a/waybar/.config/waybar/style.css b/waybar/.config/waybar/style.css index f1aad68..e97aa04 100644 --- a/waybar/.config/waybar/style.css +++ b/waybar/.config/waybar/style.css @@ -30,8 +30,7 @@ * { border: none; border-radius: 0; - /* `otf-font-awesome` is required to be installed for icons */ - /* Find Ubuntu Condensed font somewhere and install it in your system, it is NOT installed by default */ + /* `ttf-font-awesome` is required to be installed for icons */ font-family: "Fira Sans Condensed SemiBold", "Font Awesome 6 Free Solid", "Font Awesome 6 Free Regular", "Font Awesome 6 Brands Regular", sans-serif; font-size: 16px; min-height: 0; @@ -47,6 +46,10 @@ window#waybar.hidden { opacity: 0.5; } +#workspaces { + margin: 0 5px; +} + #workspaces button { background: transparent; padding: 0px; @@ -86,7 +89,8 @@ window#waybar.hidden { #mode, #idle_inhibitor, #mpd, -#custom-ivpn{ +#custom-ivpn, +#custom-usb { padding: 0 4px; margin: 0 4px; color: @white; @@ -205,3 +209,13 @@ label:focus { color: @green; box-shadow: inset 0 3px @green; } + +#custom-usb { + color: @orange; + box-shadow: inset 0 3px @orange; +} + +#custom-usb.unprotected { + color: @red; + box-shadow: inset 0 3px @red; +} diff --git a/waybar/.config/waybar/usb-status.sh b/waybar/.config/waybar/usb-status.sh new file mode 100755 index 0000000..7dcdf0b --- /dev/null +++ b/waybar/.config/waybar/usb-status.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env dash + +if usbctl check; then + TEXT="\uf023" + TOOLTIP="PROTECTED" + CLASS="protected" +else + TEXT="\uf3c1" + TOOLTIP="UNPROTECTED" + CLASS="unprotected" +fi + +env echo "{\"text\": \"${TEXT}\", \"tooltip\": \"${TOOLTIP}\", \"class\": \"${CLASS}\"}"