From 448e02e5640bed9016976875a56528c101f451d0 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 18 Nov 2018 20:26:59 +0000 Subject: [PATCH] Replace i3status-rust with polybar --- files/i3.conf | 14 +---- files/i3status-rust.toml | 43 --------------- files/launch-polybar.sh | 9 ++++ files/polybar.ini | 114 +++++++++++++++++++++++++++++++++++++++ tasks/i3.yml | 28 ++++++---- tasks/packages.yml | 2 +- 6 files changed, 145 insertions(+), 65 deletions(-) delete mode 100644 files/i3status-rust.toml create mode 100644 files/launch-polybar.sh create mode 100644 files/polybar.ini diff --git a/files/i3.conf b/files/i3.conf index 8b356cb..ee07fd0 100644 --- a/files/i3.conf +++ b/files/i3.conf @@ -131,17 +131,7 @@ exec dunst bar { status_command i3status + workspace_buttons no } -bar { - status_command i3status-rs ~/.config/i3/status.toml - position top - workspace_buttons no - binding_mode_indicator no - tray_output none - font pango:DejaVu Sans Mono, FontAwesome5Free, FontAwesome5Brands 8 - colors { - separator #666666 - statusline #dddddd - } -} +exec_always --no-startup-id {{ home }}/.config/polybar/launch.sh diff --git a/files/i3status-rust.toml b/files/i3status-rust.toml deleted file mode 100644 index 7ef694c..0000000 --- a/files/i3status-rust.toml +++ /dev/null @@ -1,43 +0,0 @@ -theme = "plain" -icons = "awesome" - -[[block]] -block = "xrandr" -interval = 5 -icons = true - -[[block]] -block = "music" -player = "spotify" -marquee = true -buttons = ["play", "next"] - -[[block]] -block = "temperature" -interval = 5 - -[[block]] -block = "memory" -format_mem = "{Mup}%" -clickable = false -interval = 2 - -[[block]] -block = "cpu" -interval = 2 - -[[block]] -block = "sound" -interval = 1 -step_width = 2 - -{% if ansible_fqdn == "TOO-Laptop" %} -[[block]] -block = "battery" -interval = 5 -{% endif %} - -[[block]] -block = "time" -interval = 1 -format = "%Y-%m-%d %T" diff --git a/files/launch-polybar.sh b/files/launch-polybar.sh new file mode 100644 index 0000000..09f3ffb --- /dev/null +++ b/files/launch-polybar.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# From: https://github.com/jaagr/polybar/issues/763#issuecomment-392960721 + +pkill polybar + +for m in $(polybar --list-monitors | cut -d":" -f1); do + MONITOR=$m polybar --reload example & +done diff --git a/files/polybar.ini b/files/polybar.ini new file mode 100644 index 0000000..009e324 --- /dev/null +++ b/files/polybar.ini @@ -0,0 +1,114 @@ +[colors] +background = #111 +foreground = #dfdfdf +primary = #285577 +secondary = #333333 +alert = #bd2c40 + +[settings] +screenchange-reload = true + +[bar/example] +monitor = ${env:MONITOR:} +width = 100% +height = 30 +fixed-center = true +background = ${colors.background} +foreground = ${colors.foreground} + +padding-right = 2 + +font-0 = "DejaVu Sans Mono:size=9;2" +font-1 = "FontAwesome5FreeSolid:size=8;2" + +modules-left = i3 xwindow +modules-center = date +modules-right = player_mpris_tail memory cpu pulseaudio power-menu + +module-margin = 2 + +wm-restack = i3 + +scroll-up = i3wm-wsnext +scroll-down = i3wm-wsprev + +cursor-click = pointer +cursor-scroll = default + + +[module/xwindow] +type = internal/xwindow +label = %title% +label-maxlen = 75 + +[module/i3] +type = internal/i3 +format = +index-sort = true +wrapping-scroll = false +pin-workspaces = true + +label-focused = %index% +label-focused-background = ${colors.primary} +label-focused-padding = 1 + +label-unfocused = ${self.label-focused} +label-unfocused-padding = 1 + +label-visible = ${self.label-focused} +label-visible-background = ${colors.secondary} +label-visible-padding = ${self.label-focused-padding} + +label-urgent = ${self.label-focused} +label-urgent-background = ${colors.alert} +label-urgent-padding = 1 + +[module/date] +type = internal/date +interval = 1 + +date = "%Y-%m-%d" +date-alt = "%c" +time = %H:%M:%S +label = %date% %time% + +[module/pulseaudio] +type = internal/pulseaudio +format-volume = +use-ui-max = false +label-muted =  MUTE +label-muted-foreground = ${colors.alert} +interval = 10 + +ramp-volume-0 =  +ramp-volume-1 =  +ramp-volume-2 =  + +[module/cpu] +type = internal/cpu +interval = 1 +label =  %percentage%% + +[module/memory] +type = internal/memory +interval = 1 +label =  %gb_used% + +[module/player_mpris_tail] +type = custom/script +exec = "python3 {{ polybar_scripts }}/player-mpris-tail/player-mpris-tail.py -f '{icon} {title} - {artist}' --icon-playing  --icon-paused " +tail = true +click-left = playerctl play-pause +click-right = playerctl next +label-maxlen = 75 + +[module/power-menu] +type = custom/menu +label-open =  +label-close =  +menu-0-0 = Shutdown +menu-0-0-foreground = #F00 +menu-0-1 = Restart +menu-0-1-foreground = #0F0 +label-separator = " | " +expand-right = false diff --git a/tasks/i3.yml b/tasks/i3.yml index 9d3f810..3664b24 100644 --- a/tasks/i3.yml +++ b/tasks/i3.yml @@ -1,16 +1,11 @@ -- template: - src: ./files/i3status-rust.toml - dest: "{{ home }}/.config/i3/status.toml" - mode: 0644 - owner: "{{ user }}" - group: users - - set_fact: + polybar_scripts: "{{ home }}/.config/polybar/polybar-scripts/polybar-scripts" i3_config_files: - {src: "i3.conf", dest: "{{ home }}/.config/i3/config"} - {src: "i3status.conf", dest: "{{ home }}/.config/i3status/config"} - {src: "compton.conf", dest: "{{ home }}/.config/compton.conf"} - {src: "dunst.conf", dest: "{{ home }}/.config/dunst/dunstrc"} + - {src: "polybar.ini", dest: "{{ home }}/.config/polybar/config"} - name: "Create i3 config file directories" with_items: "{{ i3_config_files }}" @@ -20,14 +15,29 @@ owner: "{{ user }}" mode: 0755 -- name: "Copy i3 config files" +- name: "i3 config files" with_items: "{{ i3_config_files }}" - copy: + template: src: './files/{{ item.src }}' dest: '{{ item.dest }}' mode: 0644 owner: "{{ user }}" +- name: "Polybar scripts" + git: + repo: git@github.com:x70b1/polybar-scripts + dest: "{{ home }}/.config/polybar/polybar-scripts" + force: true + become: true + become_user: "{{ user }}" + +- copy: + src: ./files/launch-polybar.sh + dest: "{{ home }}/.config/polybar/launch.sh" + mode: 0755 + owner: "{{ user }}" + group: users + - service: name: "lightdm" enabled: false diff --git a/tasks/packages.yml b/tasks/packages.yml index a13a24b..ae67c98 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -112,7 +112,6 @@ - 'htop' - 'hugo' - 'i3status' - - 'i3status-rust' - 'ibus' - 'ibus-uniemoji' - 'inkscape' @@ -145,6 +144,7 @@ - 'perl-file-mimeinfo' - 'pigz' - 'playerctl' + - 'aur/polybar' - 'postgresql' - 'postman-bin' - 'powertop'