Skip to content

Commit

Permalink
added seperate configs and changed the license
Browse files Browse the repository at this point in the history
  • Loading branch information
salman-abedin committed Jun 5, 2021
1 parent 362d74a commit 4c21b95
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 693 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

899 changes: 282 additions & 617 deletions LICENSE

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
.POSIX:
BIN_DIR = /usr/local/bin
DIR_BIN = /usr/local/bin
CONFIG = uniblocksrc
SCRIPT = $(shell grep -l "^#\!" ./* | sed 's/.\///')
init:
@[ -f ~/.config/$(CONFIG) ] || cp $(CONFIG) ~/.config
@echo Initiation finished.
install:
@mkdir -p $(BIN_DIR)
@for e in *.sh; do \
cp -f $$e $${e%.*}; \
chmod 755 $${e%.*}; \
mv $${e%.*} $(BIN_DIR); \
done
@echo Done installing executable files to $(BIN_DIR)
@mkdir -p $(DIR_BIN)
@cp -f $(SCRIPT) $(DIR_BIN)
@chmod 755 $(DIR_BIN)/${SCRIPT}
@echo Installation finished.
uninstall:
@for e in *.sh;do \
rm -f $(BIN_DIR)/$${e%.*}; \
done
@echo Done removing executable files from $(BIN_DIR)
.PHONY: install uninstall
@rm -f $(DIR_BIN)/$(SCRIPT)
@echo Uninstallation finished.
.PHONY: init install uninstall
50 changes: 21 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,46 @@
![](preview.gif)

![](screenshot.png)

# Uniblocks: Universal updatable status bar module manager
# Uniblocks: Status bar agnostic module generator

Uniblocks wraps all of your status bar modules into a single string that updates only the part that has changed.
This string can be used with any status bar application since Uniblocks itself handles all the updating.

![](https://gitlab.com/salman-abedin/assets/-/raw/master/uniblocks.gif)

![](https://gitlab.com/salman-abedin/assets/-/raw/master/uniblocks_bar.png)

## Features

- The modules can be updated without the status bar's interventions
- Updating is possible both periodically and manually
- Different modules can be updated at different intervals
- Can be used with any status bar application
- Tiny & fast ( hint: ~80 lines of POSIX shellscript with only sleep calls)
- The modules can be updated without the status bar's interventions
- Updating is possible both periodically and manually
- Different modules can be updated at different intervals
- Can be used with any status bar application
- Tiny & fast ( hint: ~80 lines of POSIX shellscript with only sleep calls)

## Dependencies

- mkfifo, sleep
- mkfifo, sleep

## Installation

```sh
git clone https://github.com/salman-abedin/uniblocks.git && cd uniblocks && sudo make install
```

## Patches

- **dwm status support**.

```sh
cd uniblocks
patch < uniblocks-dwm-10.0.diff # Add the feature
patch -R < uniblocks-dwm-10.0.diff # Remove the feature
sudo make install # Reinstall
git clone https://github.com/salman-abedin/uniblocks.git && cd uniblocks && make && sudo make install
```

## Usage

- Modify the config section of the script for your modules and reinstall afterwards
- Modify `~/.config/uniblocksrc` according to your particular status bar setup.

- Script belows commands as necessary.

| Command | Effect |
| ----------------------------- | ------------------------------------------------------------------------ |
| `uniblocks --gen,-g` | Prints the status string to standard out (The config dictates the order) |
| `uniblocks --update,-u <TAG>` | Manually updates individual module (e.g. The volume module) |
| Command | Effect |
| ----------------------------- | ----------------------------------------------------------- |
| `uniblocks --gen,-g` | Prints the status string according to the config |
| `uniblocks --update,-u <TAG>` | Manually updates individual module (e.g. The volume module) |

## Update

```sh
cd uniblocks
git pull rebase && sudo make install
git pull --no-rebase && sudo make install
```

## Uninstallation
Expand All @@ -66,6 +57,7 @@ sudo make uninstall
| Name | Description |
| ---------------------------------------------------------------------------- | ------------------------------- |
| [Alfred/panel](https://github.com/salman-abedin/alfred/blob/master/panel.sh) | The status bar modules |
| [faint](https://github.com/salman-abedin/faint) | The launcher wrapper |
| [bolt](https://github.com/salman-abedin/bolt) | The launcher wrapper |
| [tide](https://github.com/salman-abedin/puri) | Minimal Transmission CLI client |
| [puri](https://github.com/salman-abedin/puri) | Minimal URL launcher |
Expand Down
Binary file removed preview.gif
Binary file not shown.
Binary file removed screenshot.png
Binary file not shown.
30 changes: 8 additions & 22 deletions uniblocks.sh → uniblocks
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,17 @@
#
# Wraps all of your status bar modules into a single string
# that updates only the part that has changed.
#
# Dependencies: mkfifo, sleep
#
# Usage: uniblocks -g
# uniblocks -u <Tag>

#===============================================================================
# Config
#===============================================================================

# Module Format = Tag,Script,Interval (in second)
# '0' for manually updated modules
# ❗ No extra whitespaces
CONFIG="\
sys,panel -s,3;
vol,panel -v,0;
wifi,panel -w,30;
dt,panel -d,60;
"
DELIMITER=" "

#===============================================================================
# Script
#===============================================================================

PANEL_FIFO=/tmp/panel_fifo2
CONFIG=~/.config/uniblocksrc

# shellcheck source=/dev/null
. $CONFIG

parse() { # Used for parsing modules into the fifo
while IFS= read -r line; do
Expand All @@ -46,8 +33,6 @@ parse() { # Used for parsing modules into the fifo
done
}



get_config() {
CURRENT_IFS=$IFS
IFS=$(printf ';')
Expand All @@ -69,6 +54,7 @@ generate() {
TAGS=$(get_config -t) # Get tag lists from the config
mkfifo $PANEL_FIFO 2> /dev/null # Create fifo if it doesn't exist
get_config -a | parse # Parse the modules into the fifo
sleep 1; # Let the modules load properly

trap 'pkill -P $$; exit' INT TERM QUIT EXIT # Setup up trap for cleanup
while IFS= read -r line; do # Parse moudles out from the fifo
Expand All @@ -83,7 +69,7 @@ generate() {
read -r newstatus < /tmp/"$tag"
status="$status $DELIMITER $newstatus"
done
printf "\r%s" "$status" # Print the result
display "$status"
done < $PANEL_FIFO
}

Expand Down
11 changes: 0 additions & 11 deletions uniblocks-dwm-10.0.diff

This file was deleted.

22 changes: 22 additions & 0 deletions uniblocksrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# Config file for uniblocks

DELIMITER=" "

display() {
# $1 is the status string
xsetroot -name "$1" # For dwm
}

#===============================================================================
# Format: TAG,SCRIPT,INTERVAL (In second)
# Note: Use 0 as interval for manually updated modules
#===============================================================================
CONFIG="\
sys,panel -s,3;
vol,panel -v,0;
mail,panel -m,0;
wifi,panel -w,30;
dt,panel -d,60;
"

0 comments on commit 4c21b95

Please sign in to comment.