From 581e0c3daa7120ed8c306aaece377d1880b05b70 Mon Sep 17 00:00:00 2001 From: Robin Hirst <147210082+RobinHirst11@users.noreply.github.com> Date: Fri, 22 Aug 2025 21:00:03 +0100 Subject: [PATCH 1/5] Change time format from 24-hour to 12-hour --- modules/time | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/time b/modules/time index dfd2400..6541329 100755 --- a/modules/time +++ b/modules/time @@ -2,11 +2,11 @@ # Prints out the time -PREFIX=' ' +PREFIX=' ' get_time() { - echo "$PREFIX$(date '+%H:%M')" + echo "$PREFIX$(date '+%-I:%M %p')" } get_time From 13fe763c20fb2c8b5904a79734461983cc96e062 Mon Sep 17 00:00:00 2001 From: Robin Hirst <147210082+robinhirst11@users.noreply.github.com> Date: Sun, 16 Nov 2025 19:41:29 +0000 Subject: [PATCH 2/5] make a dedicated config-sync.sh script --- config-sync.sh | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ dwmbar | 33 ++++++---------- install.sh | 5 +++ 3 files changed, 119 insertions(+), 22 deletions(-) create mode 100755 config-sync.sh diff --git a/config-sync.sh b/config-sync.sh new file mode 100755 index 0000000..8ffa226 --- /dev/null +++ b/config-sync.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +set -euo pipefail + +CONFIG_DIR="${CONFIG_DIR:-$HOME/.config/dwmbar}" +DEFAULT_CONFIG_DIR="${DEFAULT_CONFIG_DIR:-/usr/share/dwmbar}" + +BASH_CONFIG="$CONFIG_DIR/config" +JSON_CONFIG="$CONFIG_DIR/config.json" +BASH_DEFAULT="$DEFAULT_CONFIG_DIR/config" +JSON_DEFAULT="$DEFAULT_CONFIG_DIR/config.json" + +command -v jq >/dev/null 2>&1 || exit 0 + +json_to_bash() { + local json_file="$1" + local bash_file="$2" + + jq -r ' + "#!/bin/bash\n\n" + + "# What modules, in what order\n" + + "MODULES=\"" + ((.modules // []) | map(tostring) | join(" ")) + "\"\n\n" + + "# Modules that require an active internet connection\n" + + "ONLINE_MODULES=\"" + ((.online_modules // []) | map(tostring) | join(" ")) + "\"\n\n" + + "# Delay between showing the status bar\n" + + "DELAY=\"" + ((.delay // "0.05")|tostring) + "\"\n\n" + + "# Where the custom modules are stored\n" + + "CUSTOM_DIR=\"" + (.custom_dir // "/home/$USER/.config/dwmbar/modules/custom/") + "\"\n\n" + + "# Separator between modules\n" + + "SEPARATOR=\"" + (.separator // " | ") + "\"\n\n" + + "# Padding at the end and beginning of the status bar\n" + + "RIGHT_PADDING=\"" + (.right_padding // " ") + "\"\n" + + "LEFT_PADDING=\"" + (.left_padding // " ") + "\"\n" + ' "$json_file" > "$bash_file" +} + +bash_to_json() { + local bash_file="$1" + local json_file="$2" + + local modules online_modules delay custom_dir separator right_padding left_padding + + modules=$(grep -E '^MODULES=' "$bash_file" | sed 's/^MODULES="\(.*\)"$/\1/' || echo "") + online_modules=$(grep -E '^ONLINE_MODULES=' "$bash_file" | sed 's/^ONLINE_MODULES="\(.*\)"$/\1/' || echo "") + delay=$(grep -E '^DELAY=' "$bash_file" | sed 's/^DELAY="\(.*\)"$/\1/' || echo "0.05") + custom_dir=$(grep -E '^CUSTOM_DIR=' "$bash_file" | sed 's/^CUSTOM_DIR="\(.*\)"$/\1/' || echo "/home/\$USER/.config/dwmbar/modules/custom/") + separator=$(grep -E '^SEPARATOR=' "$bash_file" | sed 's/^SEPARATOR="\(.*\)"$/\1/' || echo " | ") + right_padding=$(grep -E '^RIGHT_PADDING=' "$bash_file" | sed 's/^RIGHT_PADDING="\(.*\)"$/\1/' || echo " ") + left_padding=$(grep -E '^LEFT_PADDING=' "$bash_file" | sed 's/^LEFT_PADDING="\(.*\)"$/\1/' || echo " ") + + local modules_json + modules_json=$(printf '%s\n' $modules | jq -R . | jq -s .) + + local online_modules_json + online_modules_json=$(printf '%s\n' $online_modules | jq -R . | jq -s .) + + jq -n \ + --argjson modules "$modules_json" \ + --argjson online_modules "$online_modules_json" \ + --arg delay "$delay" \ + --arg custom_dir "$custom_dir" \ + --arg separator "$separator" \ + --arg right_padding "$right_padding" \ + --arg left_padding "$left_padding" \ + '{ + modules: $modules, + online_modules: $online_modules, + delay: ($delay | tonumber), + custom_dir: $custom_dir, + separator: $separator, + right_padding: $right_padding, + left_padding: $left_padding + }' > "$json_file" +} + +get_mtime() { + stat -c %Y "$1" 2>/dev/null || echo 0 +} + +mkdir -p "$CONFIG_DIR" + +if [[ ! -f "$BASH_CONFIG" && ! -f "$JSON_CONFIG" ]]; then + if [[ -f "$BASH_DEFAULT" ]]; then + cp "$BASH_DEFAULT" "$BASH_CONFIG" + fi + if [[ -f "$JSON_DEFAULT" ]]; then + cp "$JSON_DEFAULT" "$JSON_CONFIG" + fi +fi + +if [[ -f "$BASH_CONFIG" && ! -f "$JSON_CONFIG" ]]; then + bash_to_json "$BASH_CONFIG" "$JSON_CONFIG" +elif [[ -f "$JSON_CONFIG" && ! -f "$BASH_CONFIG" ]]; then + json_to_bash "$JSON_CONFIG" "$BASH_CONFIG" +elif [[ -f "$BASH_CONFIG" && -f "$JSON_CONFIG" ]]; then + bash_time=$(get_mtime "$BASH_CONFIG") + json_time=$(get_mtime "$JSON_CONFIG") + + if (( bash_time > json_time )); then + bash_to_json "$BASH_CONFIG" "$JSON_CONFIG" + elif (( json_time > bash_time )); then + json_to_bash "$JSON_CONFIG" "$BASH_CONFIG" + fi +fi diff --git a/dwmbar b/dwmbar index 3810ca6..7fd4357 100755 --- a/dwmbar +++ b/dwmbar @@ -23,6 +23,8 @@ DEFAULT_BAR_LOCATION="$DEFAULT_CONFIG_DIR/bar.sh" export DEFAULT_BAR_LOCATION DEFAULT_CONFIG_LOCATION="$DEFAULT_CONFIG_DIR/config" export DEFAULT_CONFIG_LOCATION +SYNC_SCRIPT="$DEFAULT_CONFIG_DIR/config-sync.sh" +export SYNC_SCRIPT CONFIG_DIR="/home/$USER/.config/dwmbar/" export CONFIG_DIR @@ -56,6 +58,10 @@ copy_usr_to_home(){ if [[ -f "$DEFAULT_CONFIG_DIR/config.json" ]]; then cp -r "$DEFAULT_CONFIG_DIR/config.json" "$CONFIG_DIR" fi + # Copy sync script for manual use + if [[ -f "$SYNC_SCRIPT" ]]; then + cp "$SYNC_SCRIPT" "$CONFIG_DIR/" + fi } check_files(){ @@ -107,33 +113,16 @@ check_internet() { check_files -# Prefer JSON config if present and jq is available by generating -# a bash-compatible config file in the cache directory -CONFIG_JSON_FILE="" -if [[ -f "$CONFIG_DIR/config.json" ]]; then - CONFIG_JSON_FILE="$CONFIG_DIR/config.json" -elif [[ -f "$DEFAULT_CONFIG_DIR/config.json" ]]; then - CONFIG_JSON_FILE="$DEFAULT_CONFIG_DIR/config.json" -fi - -if [[ -n "$CONFIG_JSON_FILE" ]] && command -v jq >/dev/null 2>&1; then - GEN_FILE="$CACHE_DIR/config.from_json" - jq -r --arg home "$HOME" ' - def to_bash($name; $value): $name + "=" + @sh($value); - to_bash("MODULES"; ((.modules // []) | map(tostring) | join(" "))), - to_bash("ONLINE_MODULES"; ((.online_modules // []) | map(tostring) | join(" "))), - to_bash("DELAY"; ((.delay // "0.05")|tostring)), - to_bash("CUSTOM_DIR"; (.custom_dir // ($home + "/.config/dwmbar/modules/custom/"))), - to_bash("SEPARATOR"; (.separator // " | ")), - to_bash("RIGHT_PADDING"; (.right_padding // " ")), - to_bash("LEFT_PADDING"; (.left_padding // " ")) - ' "$CONFIG_JSON_FILE" > "$GEN_FILE" && CONFIG_FILE="$GEN_FILE" && export CONFIG_FILE -fi +# Run config sync once at startup to ensure configs are in sync +[[ -x "$SYNC_SCRIPT" ]] && "$SYNC_SCRIPT" 2>/dev/null || true while :; do date=$(date +'%S') if [ $(( 10#$date % 5 )) -eq 0 ]; then INTERNET=$(check_internet) + # Sync again periodically in case user edits config + [[ -x "$SYNC_SCRIPT" ]] && "$SYNC_SCRIPT" 2>/dev/null || true + sleep 1 fi xsetroot -name "$(exec $DEFAULT_BAR_LOCATION)" done diff --git a/install.sh b/install.sh index a36b27b..91a34f0 100755 --- a/install.sh +++ b/install.sh @@ -41,6 +41,11 @@ if [[ -f "$REPO_ROOT/config.json" ]]; then install -m 0644 "$REPO_ROOT/config.json" "$SHARE_DIR/config.json" fi +# Install config sync script if present +if [[ -f "$REPO_ROOT/config-sync.sh" ]]; then + install -m 0755 "$REPO_ROOT/config-sync.sh" "$SHARE_DIR/config-sync.sh" +fi + install -m 0755 "$REPO_ROOT/dwmbar" "$BIN_DEST" echo "Installation completed successfully." From 4737b371452977d3bb232f905b495ef7b1a869ec Mon Sep 17 00:00:00 2001 From: Robin Hirst <147210082+RobinHirst11@users.noreply.github.com> Date: Sun, 16 Nov 2025 19:44:57 +0000 Subject: [PATCH 3/5] fix CI failing from shellcheck warning Shellcheck doesn't like A && B || C because if B fails, C will run even when A is true.. just fixed with an if statement --- dwmbar | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dwmbar b/dwmbar index 7fd4357..24147e7 100755 --- a/dwmbar +++ b/dwmbar @@ -114,7 +114,9 @@ check_internet() { check_files # Run config sync once at startup to ensure configs are in sync -[[ -x "$SYNC_SCRIPT" ]] && "$SYNC_SCRIPT" 2>/dev/null || true +if [[ -x "$SYNC_SCRIPT" ]]; then + "$SYNC_SCRIPT" 2>/dev/null || true +fi while :; do date=$(date +'%S') From 4d91c997174842a1cd8444c10e1c235176d9225b Mon Sep 17 00:00:00 2001 From: Robin Hirst <147210082+RobinHirst11@users.noreply.github.com> Date: Sun, 16 Nov 2025 19:47:31 +0000 Subject: [PATCH 4/5] oops... it happens again in a later line --- dwmbar | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dwmbar b/dwmbar index 24147e7..a038c93 100755 --- a/dwmbar +++ b/dwmbar @@ -123,8 +123,10 @@ while :; do if [ $(( 10#$date % 5 )) -eq 0 ]; then INTERNET=$(check_internet) # Sync again periodically in case user edits config - [[ -x "$SYNC_SCRIPT" ]] && "$SYNC_SCRIPT" 2>/dev/null || true - sleep 1 + if [[ -x "$SYNC_SCRIPT" ]]; then + "$SYNC_SCRIPT" 2>/dev/null || true + fi + sleep 1 fi xsetroot -name "$(exec $DEFAULT_BAR_LOCATION)" done From b7163d82435eb653e050656822588235fce0d2e3 Mon Sep 17 00:00:00 2001 From: Robin Hirst <147210082+RobinHirst11@users.noreply.github.com> Date: Wed, 19 Nov 2025 11:08:10 +0000 Subject: [PATCH 5/5] Update README with installation instructions Added sections for installation methods and a placeholder for additional content. Add files via upload add an image of dwmbar in README Updated README with a new screenshot of dwmbar Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update README with installation instructions (#46) Added sections for installation methods and a placeholder for additional content. Add files via upload add an image of dwmbar in README Updated README with a new screenshot of dwmbar Update README.md Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 25 +++++++++++++++++++++---- res/bar.png | Bin 0 -> 2777 bytes 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 res/bar.png diff --git a/README.md b/README.md index 661f9d5..926fbd5 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ dwmbar - A Modular Status Bar for dwm ===================================== ![Example image](res/example.png) +

+ + dwmbar is a very simple status bar written for dwm. **Maintenance status:** Historically this project was unmaintained. Community maintenance is now being taken on by [robinhirst11](https://github.com/RobinHirst11/), who is willing to steward fixes and improvements. Issues and PRs are welcome. @@ -20,8 +23,10 @@ Optional (By module): See [module prerequisites](#module-prerequisites). +## Installation Methods -## Arch Linux +

+Arch Linux There is an [AUR package](https://aur.archlinux.org/packages/dwmbar-git) for dwmbar, which can be installed with your favourite aur helper, or manually. @@ -29,14 +34,26 @@ dwmbar, which can be installed with your favourite aur helper, or manually. Please see the [archwiki page](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages) for how to manually install AUR packages. - -## Manual Installation - ```bash $ git clone https://github.com/thytom/dwmbar $ cd dwmbar $ sudo ./install.sh ``` +
+ +
+Automated install + +There is an automated download and install script for +dwmbar, which can be installed with the following command +```bash +curl -fsSL https://dwmbar.robinhirst.qzz.io/install.sh | bash +``` +Please ensure you always check scripts before executing them, if you're running an esoteric system like NixOS or LFS, this script expect you to know what you're doing. + +As we can't support everything, this has currently only been tested on Arch Linux. +
+ # Usage dwmbar works by setting the root window name, which dwm displays. It does this diff --git a/res/bar.png b/res/bar.png new file mode 100644 index 0000000000000000000000000000000000000000..d809dc1a5a08e0108d69186f844d7165eaec2b9a GIT binary patch literal 2777 zcmV;~3MTc5P)7Ota|R8C4FA0Rh0GHYX9 z$-Jw5bZo)2q>+bxrJ9Z`DJe5BE)o$Fx2v6MVq8N$JIA`JjDmO%4iGvvG!zpQr<{*` zb88I@4nI0MkA!+IDk`j?l6P=tVq8_VsG7;UtFxw=T~|`Qu%T&TTeYd1$hxacNJOoo zluk)SaA{$~wx%g2Ca9f}&%v-OC@8$Iph`tTdU9&UxTqKw7`CdMacW|8Y-BAdDvg7A zx~`vkacLA16veoxDkdk!xv89zg>7YCy|JOOrkAy-n<5|}FDomcl!$R@Vwa7A3=0mQ zl!!ezH-LC=Zf0L>WL}4UbXQSK9vdB4QBA9#l2S}aSyD|fEi746PD@5Zb8KX8XJF32 zuwz|TC?+L4I5vTJZ;pg{6%!T0wWh$cqo9?EgL`qFl!ujzfRu`Ws-KY#4G zH#L)reSGA=DPGB7tYF}batdva?fA|j}qkY`|8PfA9Zj)Rhj zeL*}r%)YK085^*qmXU{iTvkz_JFe3J00*T>L_t(|ob6b9R83hN{%w&6jawdLF>9!m zM>HCtNO@PIn#!P&OSiI86nPVpFhnA+P|0M`7>`CCc~sM5%9Tf^@=R!^VH)o|@)%~H z(>eR>bI-j!j4?B$MNp4A1oUqUsK@(6y`6Om^>)@NyaziG zLVx~!mWJq6?FVTiRG}u^s3Cf$8hbw~-xVJ!yI`j-deR)B@;9}nXsV4KhypTnk7*1L zDyuO`8-#AxHgP*#Bvhj2hAvKhqZ*Z+5R1#T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