aboutsummaryrefslogtreecommitdiff
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
parente351037f1e0f48a2a1602a07d376980c9e595091 (diff)
downloadswayrice-cbfd974f652a12c601a95ea6d364549f45cb87e3.tar.gz
swayrice-cbfd974f652a12c601a95ea6d364549f45cb87e3.zip
improved script for pacman package download cron job; waybar improvements
-rw-r--r--dotfiles/.config/waybar/config13
-rw-r--r--dotfiles/.config/waybar/style.css2
-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
9 files changed, 110 insertions, 15 deletions
diff --git a/dotfiles/.config/waybar/config b/dotfiles/.config/waybar/config
index 6d5903b..a0f95ba 100644
--- a/dotfiles/.config/waybar/config
+++ b/dotfiles/.config/waybar/config
@@ -16,7 +16,9 @@
"modules-right": [
"custom/rec-status",
"custom/swaykbd",
+ "custom/ds4battery",
"backlight",
+ "custom/pac-status",
"custom/vpn-status",
"network",
"battery#bat0",
@@ -174,11 +176,22 @@
"interval": "once",
"exec": "barvpnstatus"
},
+ "custom/pac-status": {
+ "format": "<span color=\"#5b8277\">๎˜‰</span> {}",
+ "signal": 7,
+ "interval": "once",
+ "exec": "barpacstatus"
+ },
"custom/weather": {
"format": "{}",
"interval": 180,
"exec": "barweather"
},
+ "custom/ds4battery": {
+ "format": "๐ŸŽฎ {}",
+ "interval": 180,
+ "exec": "bards4battery"
+ },
"custom/swaykbd": {
"format": "{}",
"exec": "swaykbd",
diff --git a/dotfiles/.config/waybar/style.css b/dotfiles/.config/waybar/style.css
index e066c6a..ce29c25 100644
--- a/dotfiles/.config/waybar/style.css
+++ b/dotfiles/.config/waybar/style.css
@@ -62,8 +62,10 @@ window#waybar {
#pulseaudio,
#temperature,
#custom-weather,
+#custom-ds4battery,
#custom-rec-status,
#custom-vpn-status,
+#custom-pac-status,
#custom-swaykbd {
padding: 0 6px;
}
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'