From 6f35662f0cc1f885211af7efef55e80e2b3df240 Mon Sep 17 00:00:00 2001 From: Mastermindzh Date: Thu, 9 Mar 2023 10:21:15 +0100 Subject: [PATCH] adding polybar setup --- README.md | 20 ++- config/autorandr/postswitch | 35 ++++ config/gtk-3.0/settings.ini | 4 +- config/polybar/config.ini | 26 +++ config/polybar/launch.sh | 25 +++ config/polybar/scripts/pulse-microphone.sh | 59 +++++++ config/polybar/themes/main/bars.ini | 36 +++++ config/polybar/themes/main/colors.ini | 11 ++ config/polybar/themes/main/modules.ini | 180 +++++++++++++++++++++ dependencies/aur.txt | 1 + dependencies/pacman.txt | 4 + i3/config | 43 ++--- i3/scripts/tidal-cli.sh | 8 + install.sh | 5 + media/dotfiles6.png | Bin 0 -> 2654067 bytes 15 files changed, 427 insertions(+), 30 deletions(-) create mode 100755 config/autorandr/postswitch create mode 100644 config/polybar/config.ini create mode 100755 config/polybar/launch.sh create mode 100755 config/polybar/scripts/pulse-microphone.sh create mode 100644 config/polybar/themes/main/bars.ini create mode 100644 config/polybar/themes/main/colors.ini create mode 100644 config/polybar/themes/main/modules.ini create mode 100644 media/dotfiles6.png diff --git a/README.md b/README.md index 8aa02d4..5c27caa 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,17 @@ This repository holds my Linux config files. ## Mandatory unixporn screenshots -New version as of Nov 2022: +New version as of January 2023: -[![dotfiles](media/dotfiles5.png)](https://raw.githubusercontent.com/Mastermindzh/dotfiles/master/media/dotfiles5.png) +[![dotfiles](media/dotfiles6.png)](media/dotfiles6.png) -I changed color of the terminal to match the i3bar: +I changed the color of the terminal to match the i3bar: Older versions: +- [dotfiles5](media/dotfiles5.png) - [dotfiles4](https://raw.githubusercontent.com/Mastermindzh/dotfiles/master/media/dotfiles4.jpg) - [dotfiles3](media/dotfiles3.png) - [dotfiles2](media/dotfiles2.png) @@ -24,6 +25,7 @@ Older versions: | Purpose | Tool | | ---------------- | ---------------------------------------------------------------------- | | WM | i3 (i3-gaps) | +| bar | polybar | | App launcher | rofi | | Shell | Bash | | Package managers | Pacman & Trizen | @@ -32,13 +34,12 @@ Older versions: | Editor | nano | | Code editor | vscode | | Browser | Firefox | -| File manager | If I have to use one ... Thunar | +| File manager | If I have to use one ... Thunar | | Music | Tidal through [Tidal-hifi](https://github.com/Mastermindzh/tidal-hifi) | -| | | ## computer specifc setup -Nowadays I use a few different computers and I'd used to apply the base config and configure each pc on its own. +Nowadays I use a few different computers and I used to apply the base config and configure each pc on its own. I've grown tired of this approach however so I added a "pc specific" setup in the installer. The pc specific setup bit will read the folder names in computers, offer you a choice, and execute the install.sh inside that folder. @@ -46,14 +47,17 @@ This allows me to get pc specific settings synced with git and applied easily. ## Getting x info to use in i3 -Some things are handled by window class/title or have custom resolutions set, the tools below help obtaining the info required: +Some things are handled by window class/title or have custom resolutions set, the tools below help obtain the info required: - xprop -> displays static xwindow info including Window class - xwininfo -> displays xwindow info including current size/position ## getting icons -Copy/paste icons from this url: [https://fontawesome.com/v5/cheatsheet](https://fontawesome.com/v5/cheatsheet) +Copy/paste icons from these URLs: + +- [https://fontawesome.com/v5/cheatsheet](https://fontawesome.com/v5/cheatsheet) +- [https://fonts.google.com/noto/specimen/Noto+Color+Emoji/glyphs?noto.query=noto+color+emoji](https://fonts.google.com/noto/specimen/Noto+Color+Emoji/glyphs?noto.query=noto+color+emoji) ## after-install diff --git a/config/autorandr/postswitch b/config/autorandr/postswitch new file mode 100755 index 0000000..fdbec08 --- /dev/null +++ b/config/autorandr/postswitch @@ -0,0 +1,35 @@ +#!/bin/bash -x + +move_workspace() { + workspace="$1" + output="$2" + + i3-msg "[workspace=\"$workspace\"]" move workspace to output "$output" +} +export -f move_workspace + +# get primary +primary=$(xrandr | awk '/ primary / {print $1}') + +declare -a movers=( + "1: " + "2: " + "3: " + "4: " + "5: " + "6: " + "7: " + "8: " + "9: " + "10: " + # "11:  " + "12: " + "13: " +) + +for workspace in "${movers[@]}"; do + move_workspace "$workspace" "$primary" & +done + +# restart i3. +i3-msg restart diff --git a/config/gtk-3.0/settings.ini b/config/gtk-3.0/settings.ini index 72a10f6..f87c804 100644 --- a/config/gtk-3.0/settings.ini +++ b/config/gtk-3.0/settings.ini @@ -1,7 +1,7 @@ [Settings] gtk-theme-name=Adwaita-dark -gtk-icon-theme-name=Adwaita -gtk-font-name=Cantarell 11 +gtk-icon-theme-name="Papirus-Dark" +gtk-font-name="Ubuntu 12" gtk-cursor-theme-name=Adwaita gtk-cursor-theme-size=0 gtk-toolbar-style=GTK_TOOLBAR_BOTH diff --git a/config/polybar/config.ini b/config/polybar/config.ini new file mode 100644 index 0000000..218fa0b --- /dev/null +++ b/config/polybar/config.ini @@ -0,0 +1,26 @@ +;========================================================== +; +; +; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ +; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ +; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ +; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ +; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ +; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ +; +; +; To learn more about how to configure Polybar +; go to https://github.com/polybar/polybar +; +; The README contains a lot of information +; +;========================================================== + +[settings] +screenchange-reload = true +pseudo-transparency = true + +; theme +include-file = ~/.config/polybar/themes/main/modules.ini +include-file = ~/.config/polybar/themes/main/colors.ini +include-file = ~/.config/polybar/themes/main/bars.ini diff --git a/config/polybar/launch.sh b/config/polybar/launch.sh new file mode 100755 index 0000000..5a0fd93 --- /dev/null +++ b/config/polybar/launch.sh @@ -0,0 +1,25 @@ +#!/bin/bash +killall -q polybar + +# Launch Polybar, using default config location ~/.config/polybar/config.ini +PRIMARY=$(xrandr --query | grep -i "connected primary" | cut -d" " -f1) +export MONITOR=$PRIMARY +polybar -r 2>&1 | tee -a /tmp/polybar.log & + +# show-bar on all monitors +# idk whether I like this at the moment, I don't really use external displays unless they are the primary or they are duplicated +# if type "xrandr"; then +# PRIMARY=$(xrandr --query | grep -i "connected primary" | cut -d" " -f1) +# for m in $(xrandr --query | grep -i " connected" | cut -d" " -f1); do +# export TRAY_POSITION=none +# if [[ $m == "$PRIMARY" ]]; then +# TRAY_POSITION=right +# fi +# export MONITOR=$m +# polybar -r 2>&1 | tee -a /tmp/polybar.log & +# done +# else +# polybar -r 2>&1 | tee -a /tmp/polybar.log & +# fi +disown +echo "Polybar launched..." diff --git a/config/polybar/scripts/pulse-microphone.sh b/config/polybar/scripts/pulse-microphone.sh new file mode 100755 index 0000000..2a96aae --- /dev/null +++ b/config/polybar/scripts/pulse-microphone.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +status() { + MUTED=$(pacmd list-sources | awk '/\*/,EOF {print}' | awk '/muted/ {print $2; exit}') + + if [ "$MUTED" = "yes" ]; then + echo "🙊 muted" + else + OUTPUT=$(pacmd list-sources | grep "\* index:" -A 7 | grep volume | awk -F/ '{print $2}' | awk -F, '{ print $1 }' | tr -d ' ') + echo "🎙️ $OUTPUT" + fi +} + +listen() { + status + + LANG=EN + pactl subscribe | while read -r event; do + if echo "$event" | grep -q "source" || echo "$event" | grep -q "server"; then + status + fi + done +} + +toggle() { + MUTED=$(pacmd list-sources | awk '/\*/,EOF {print}' | awk '/muted/ {print $2; exit}') + DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}') + + if [ "$MUTED" = "yes" ]; then + pactl set-source-mute "$DEFAULT_SOURCE" 0 + else + pactl set-source-mute "$DEFAULT_SOURCE" 1 + fi +} + +increase() { + DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}') + pactl set-source-volume "$DEFAULT_SOURCE" +5% +} + +decrease() { + DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}') + pactl set-source-volume "$DEFAULT_SOURCE" -5% +} + +case "$1" in +--toggle) + toggle + ;; +--increase) + increase + ;; +--decrease) + decrease + ;; +*) + listen + ;; +esac diff --git a/config/polybar/themes/main/bars.ini b/config/polybar/themes/main/bars.ini new file mode 100644 index 0000000..39c01ab --- /dev/null +++ b/config/polybar/themes/main/bars.ini @@ -0,0 +1,36 @@ +[bar/main] +monitor = ${env:MONITOR:} +width = 100% +height = 18pt +radius = 0 +padding-right = 0 +padding-left = 0 +module-margin = 1 +separator = | + +; colors +background = ${colors.background} +foreground = ${colors.foreground} +border-color = #00000000 +separator-foreground = ${colors.disabled} + +; modules +modules-left = xworkspaces i3 +modules-center = tidal +modules-right = pulseaudio pulseaudio-microphone weather temperature updates ping battery date + +; fonts (fc-list) +; offset = height - size / 2 (for vertical center, icons are weird and need to be even numbers) +font-0 = Ubuntu regular:style=regular:size=12;3 +font-1 = FontAwesome:style=Regular;2 +font-2 = Noto Color Emoji:style=Regular:scale=10;2 + +cursor-click = pointer +cursor-scroll = ns-resize + +enable-ipc = true +tray-position = ${env:TRAY_POSITION:right} + +wm-restack = i3 +tray-reparent = true +; override-redirect = true diff --git a/config/polybar/themes/main/colors.ini b/config/polybar/themes/main/colors.ini new file mode 100644 index 0000000..d10cf3c --- /dev/null +++ b/config/polybar/themes/main/colors.ini @@ -0,0 +1,11 @@ +[colors] +background = #1e1e1e +background-alt = #252526 +foreground = #848484 +primary = #f6f6f7 +secondary = #f6f6f7 +alert = #ef5350 +disabled = #707880 +accent = #fff +yellow = #ebc034 +tidal = #00ffff diff --git a/config/polybar/themes/main/modules.ini b/config/polybar/themes/main/modules.ini new file mode 100644 index 0000000..d3184fe --- /dev/null +++ b/config/polybar/themes/main/modules.ini @@ -0,0 +1,180 @@ +[module/xworkspaces] +type = internal/xworkspaces +pin-workspaces = true + +label-active = %name% +label-active-background = ${colors.background-alt} +; label-active-underline= ${colors.primary} +label-active-foreground= ${colors.accent} +label-active-padding = 1 + +label-occupied = %name% +label-occupied-padding = 1 + +label-urgent = %name% +label-urgent-background = ${colors.alert} +label-urgent-padding = 1 + +label-empty = %name% +label-empty-foreground = ${colors.disabled} +label-empty-padding = 1 + + +[module/pulseaudio] +type = internal/pulseaudio + +format-volume-prefix = "🔊 " +; format-volume-prefix = " " +format-volume-prefix-foreground = ${colors.primary} +format-volume = + +label-volume = %percentage%% + + +; label-muted = 🔇 muted +label-muted = 🙉 muted +label-muted-foreground = ${colors.disabled} + +[module/memory] +type = internal/memory +interval = 2 +format-prefix = " " +format-prefix-foreground = ${colors.primary} +label = %percentage_used:2%% + +[module/cpu] +type = internal/cpu +interval = 2 +format-prefix = " " +format-prefix-foreground = ${colors.primary} +label = %percentage:2%% + +[module/date] +type = internal/date +interval = 1 + +date = %Y-%m-%d %H:%M:%S + +format-prefix = "📅 " +; format-prefix = " " +format-prefix-foreground = ${colors.primary} +label =%date% + +[module/temperature] +type = internal/temperature + +base-temperature = 40 +warn-temperature = 80 + +# format-prefix = " " +# format-warn-prefix = " " +format-prefix = "🌡️" +format-warn-prefix = "🌡️" +format-prefix-foreground = ${colors.accent} + +label = %temperature-c% +format-warn =