aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2020-04-06 02:30:09 +0300
committerYaroslav <contact@yaroslavps.com>2020-04-06 02:30:09 +0300
commitcbfd974f652a12c601a95ea6d364549f45cb87e3 (patch)
tree06ad8bd90f653102065d4028d64a274f6d9bcd39 /dotfiles/.local
parente351037f1e0f48a2a1602a07d376980c9e595091 (diff)
downloadswayrice-cbfd974f652a12c601a95ea6d364549f45cb87e3.tar.gz
swayrice-cbfd974f652a12c601a95ea6d364549f45cb87e3.zip
improved script for pacman package download cron job; waybar improvements
Diffstat (limited to 'dotfiles/.local')
-rwxr-xr-xdotfiles/.local/bin/bards4battery15
-rwxr-xr-xdotfiles/.local/bin/barpacstatus16
-rwxr-xr-xdotfiles/.local/bin/paccheck10
-rwxr-xr-xdotfiles/.local/bin/pacsync27
-rwxr-xr-xdotfiles/.local/bin/pacupgrade13
-rwxr-xr-xdotfiles/.local/bin/setsessionenv21
-rwxr-xr-xdotfiles/.local/bin/swaykbd8
7 files changed, 95 insertions, 15 deletions
diff --git a/dotfiles/.local/bin/bards4battery b/dotfiles/.local/bin/bards4battery
new file mode 100755
index 0000000..15ffb99
--- /dev/null
+++ b/dotfiles/.local/bin/bards4battery
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if [ -f /sys/class/power_supply/sony_controller_battery_*/capacity ]; then
+ percentage=$(cat /sys/class/power_supply/sony_controller_battery_*/capacity)
+
+ if [ percentage -lt 40 ]; then
+ printf "<span color=\"#b2872f\">%s%%</span>" "$percentage"
+ exit
+ fi
+ if [ percentage -lt 20 ]; then
+ printf "<span color=\"#b73030\">%s%%</span>" "$percentage"
+ exit
+ fi
+ printf "<span color=\"#5b8277\">%s%%</span>" "$percentage"
+fi
diff --git a/dotfiles/.local/bin/barpacstatus b/dotfiles/.local/bin/barpacstatus
new file mode 100755
index 0000000..3a05525
--- /dev/null
+++ b/dotfiles/.local/bin/barpacstatus
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if [ -f ~/.cache/pacsynclive ]; then
+ echo "syncing"
+ exit
+fi
+if [ -f ~/.cache/pacupgradelive ]; then
+ echo "installing"
+ exit
+fi
+
+upno=$(pacman -Qu | wc -l)
+
+if [ $upno -gt 0 ]; then
+ echo $upno
+fi
diff --git a/dotfiles/.local/bin/paccheck b/dotfiles/.local/bin/paccheck
deleted file mode 100755
index 1284134..0000000
--- a/dotfiles/.local/bin/paccheck
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-ping -q -c 1 1.1.1.1 > /dev/null || exit
-
-notify-send "⬆ Update check" "Checking for updates..."
-
-sudo pacman -Sy
-upno=$(pacman -Qu | wc -l)
-
-notify-send "⬆ Update Check" "$upno updates are available"
diff --git a/dotfiles/.local/bin/pacsync b/dotfiles/.local/bin/pacsync
new file mode 100755
index 0000000..30fc98c
--- /dev/null
+++ b/dotfiles/.local/bin/pacsync
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if pidof pacman; then
+ exit
+fi
+
+ping -q -c 1 1.1.1.1 > /dev/null || exit
+
+# Source the needed env variables so that it can function properly from cron
+. ~/.cache/sessionenv
+
+notify-send " System upgrade" "Syncing repositories and downloading packages..."
+
+touch ~/.cache/pacsynclive
+killall -41 waybar
+
+sudo pacman -Syuw --noconfirm || notify-send " System upgrade" \
+ "Error downloading updates. Check your internet connection or that you have the required permissions"
+
+rm -f ~/.cache/pacsynclive
+killall -41 waybar
+
+upno=$(pacman -Qu | wc -l)
+
+if [ $upno -lt 0 ]; then
+ notify-send " System upgrade" "Repository sync finished. $upno updates are available"
+fi
diff --git a/dotfiles/.local/bin/pacupgrade b/dotfiles/.local/bin/pacupgrade
new file mode 100755
index 0000000..4aa4512
--- /dev/null
+++ b/dotfiles/.local/bin/pacupgrade
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if pidof pacman; then
+ exit
+fi
+
+touch ~/.cache/pacupdatelive
+killall -41 waybar
+
+sudo pacman -Syu
+
+rm -f ~/.cache/pacupdatelive
+killall -41 waybar
diff --git a/dotfiles/.local/bin/setsessionenv b/dotfiles/.local/bin/setsessionenv
new file mode 100755
index 0000000..8d8459d
--- /dev/null
+++ b/dotfiles/.local/bin/setsessionenv
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Create a file with the env variables of the current wayland session so that
+# cron scripts can source it and function properly
+
+printf "export DISPLAY=%s
+export WAYLAND_DISPLAY=%s
+export XDG_SESSION_ID=%s
+export XDG_SESSION_CLASS=%s
+export XDG_SEAT=%s
+export XDG_RUNTIME_DIR=%s
+export I3SOCK=%s
+export SWAYSOCK=%s"\
+ "$DISPLAY" \
+ "$WAYLAND_DISPLAY" \
+ "$XDG_SESSION_ID" \
+ "$XDG_SESSION_CLASS" \
+ "$XDG_SEAT" \
+ "$XDG_RUNTIME_DIR" \
+ "$I3SOCK" \
+ "$SWAYSOCK" > ~/.cache/sessionenv
diff --git a/dotfiles/.local/bin/swaykbd b/dotfiles/.local/bin/swaykbd
index d90f78c..2ec42c3 100755
--- a/dotfiles/.local/bin/swaykbd
+++ b/dotfiles/.local/bin/swaykbd
@@ -3,7 +3,7 @@
swaymsg -r -t get_inputs | \
grep "xkb_active_layout_name" | \
awk -F '"' '{print $4}' | \
- sed 's/English (US)/🇺🇸 English/g;s/Spanish/🇲🇽 Español/g;s/Russian/🇷🇺 Русский/g' | head -1
+ sed --unbuffered 's/English (US)/🇺🇸 EN/g;s/Spanish/🇲🇽 ES/g;s/Russian/🇷🇺 RU/g'| head -1
swaymsg \
--type subscribe \
@@ -14,8 +14,6 @@ swaymsg \
--raw-output \
--unbuffered \ '
select(.change == "xkb_layout") |
- .input.xkb_active_layout_name |
- sub(" \\(US\\)"; "")
- ' | \
- sed --unbuffered 's/English/🇺🇸 English/g;s/Spanish/🇲🇽 Español/g;s/Russian/🇷🇺 Русский/g'
+ .input.xkb_active_layout_name' | \
+ sed --unbuffered 's/English (US)/🇺🇸 EN/g;s/Spanish/🇲🇽 ES/g;s/Russian/🇷🇺 RU/g'