aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authordenis-ismailaj2024-03-24 12:02:08 +0100
committerdenis-ismailaj2024-03-24 12:13:39 +0100
commitb3ac1e76d9c172ab1f1d7a903e02da3eaad076ee (patch)
tree2de3ab791f05c77719d6044f66bcf777fcb2ba5e
parente0c88744554a8c24f2c69344e08558b3a59c84be (diff)
downloadaur-b3ac1e76d9c172ab1f1d7a903e02da3eaad076ee.tar.gz
Update package
-rw-r--r--.SRCINFO17
-rw-r--r--PKGBUILD7
-rw-r--r--README.md39
-rwxr-xr-xi3-auto-arrange15
-rwxr-xr-xi3-auto-arrange.sh16
5 files changed, 56 insertions, 38 deletions
diff --git a/.SRCINFO b/.SRCINFO
index b70967d72ff3..bcdd64b26ff2 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,12 +1,11 @@
pkgbase = i3-auto-arrange
- pkgdesc = This is a simple Shell script that will automatically rearrange i3 workspaces
- pkgver = 1.0.2
- pkgrel = 1
- url = https://github.com/denis-ismailaj/i3-auto-arrange
- arch = any
- license = GPL3
- depends = i3-wm
- depends = jq
+ pkgdesc = Rearrange i3 workspaces to get rid of gaps in numbering
+ pkgver = 1.0.3
+ pkgrel = 1
+ url = https://github.com/denis-ismailaj/i3-auto-arrange
+ arch = any
+ license = GPL3
+ depends = i3-wm
+ depends = jq
pkgname = i3-auto-arrange
-
diff --git a/PKGBUILD b/PKGBUILD
index 96fffb605b6d..2ab551f5e499 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,14 +1,13 @@
# Maintainer: Denis Ismailaj <denis.ismailaj1@gmail.com>
pkgname=i3-auto-arrange
-pkgver=1.0.2
+pkgver=1.0.3
pkgrel=1
-pkgdesc="This is a simple Shell script that will automatically rearrange i3 workspaces"
+pkgdesc="Rearrange i3 workspaces to get rid of gaps in numbering"
arch=('any')
url="https://github.com/denis-ismailaj/i3-auto-arrange"
license=('GPL3')
depends=('i3-wm' 'jq')
package() {
- sudo cp "$startdir/i3-auto-arrange" /usr/bin
+ install -D -m 755 "$srcdir/i3-auto-arrange" "$pkgdir/usr/bin/i3-auto-arrange"
}
-
diff --git a/README.md b/README.md
index c730e348e155..a23408e4ee96 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,36 @@
# i3-auto-arrange
-This tool is designed to help you when you have many workspaces open in `i3`, and when you close some of them you end up with gaps in the numbering. Instead of arranging them one by one, you can run `i3-auto-arrange` and it will automatically do it for you.
+
+Opening and closing many workspaces in `i3` can lead to gaps in numbering.
+
+Instead of rearranging them yourself, you can have `i3-auto-arrange` do it for you.
### Installation
-You can find this script as a package on the AUR (Arch User Repository): https://aur.archlinux.org/packages/i3-auto-arrange
-Using a package helper such as `yay`, you could run `yay -S i3-auto-arrange`
+This script is available as an [AUR package](https://aur.archlinux.org/packages/i3-auto-arrange).
+
+You can use an AUR helper such as `yay` to install it:
+
+ yay -S i3-auto-arrange
-Or, to install from source instead:
+Or, to install from source:
```
-$ git clone https://github.com/denis-ismailaj/i3-auto-arrange.git
-$ cd i3-auto-arrange
-$ makepkg
+git clone https://github.com/denis-ismailaj/i3-auto-arrange.git
+cd i3-auto-arrange
+makepkg
+sudo pacman -U i3-auto-arrange-*.pkg.tar.xz
```
-### Dependencies
-- `i3-wm` (obviously)
-- `jq` (needed to parse output from `i3-msg`)
+
+> [!NOTE]
+> `i3-auto-arrange` depends on `jq` in order to parse the outputs of `i3-msg`
+
+### Usage
+
+`i3-auto-arrange` is most useful when used as a keyboard shortcut.
+
+To do that, open your `i3` config file:
+
+ vim ~/.config/i3/config # or ~/.i3/config
+
+and bind your preferred key combination to running `i3-auto-arrange`:
+
+ bindsym <key combination> exec i3-auto-arrange
diff --git a/i3-auto-arrange b/i3-auto-arrange
deleted file mode 100755
index ed5d2310dde2..000000000000
--- a/i3-auto-arrange
+++ /dev/null
@@ -1,15 +0,0 @@
-# /bin/sh
-
-workspaces=$(i3-msg -t get_workspaces)
-num=$(echo $workspaces | jq length)
-
-for ((i=0;i<$num;i++))
-do
- current=$(echo $workspaces | jq ".[$i].num")
- normal=$(($i + 1))
-
- if (($current != $normal))
- then
- i3-msg -q rename workspace "$current" to "$normal"
- fi
-done
diff --git a/i3-auto-arrange.sh b/i3-auto-arrange.sh
new file mode 100755
index 000000000000..37f700bb762b
--- /dev/null
+++ b/i3-auto-arrange.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+workspaces=$(i3-msg -t get_workspaces)
+n_workspaces=$(echo "$workspaces" | jq length)
+
+i=0
+while [ "$i" -lt "$n_workspaces" ]
+do
+ current_number=$(echo "$workspaces" | jq ".[$i].n_workspaces")
+ expected_number=$($i + 1)
+
+ if [ "$current_number" -ne "$expected_number" ]
+ then
+ i3-msg -q rename workspace "$current_number" to "$expected_number"
+ fi
+done