aboutsummaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2021-11-29 13:11:54 -0700
committerJosh Rahm <joshuarahm@gmail.com>2021-11-29 13:11:54 -0700
commitedf2bd9db98a367261debe56ad2f4f6fb61b6c09 (patch)
tree52f5343a37e06d5b4d1914a7a5d00807e3f16497 /extras
parentc5a27bb21f012a521e90350d4322c458f3a3e618 (diff)
downloadrde-edf2bd9db98a367261debe56ad2f4f6fb61b6c09.tar.gz
rde-edf2bd9db98a367261debe56ad2f4f6fb61b6c09.tar.bz2
rde-edf2bd9db98a367261debe56ad2f4f6fb61b6c09.zip
Add some changes.
1. Make the spotify control work for both Spotify and Spotifyd 2. Xmobar weather not break xmobar when not connected to the internet 3. Add g<space> keybinding to go to the toogle-cased version of the current workspace.
Diffstat (limited to 'extras')
-rwxr-xr-xextras/HOME/.local/bin/set-backlight.sh35
-rwxr-xr-xextras/HOME/.local/bin/spotify-control31
-rw-r--r--extras/HOME/.xmobarrc10
-rwxr-xr-xextras/HOME/.xmonad/xmobar-bluetooth2
-rwxr-xr-xextras/HOME/.xmonad/xmobar-weather5
5 files changed, 70 insertions, 13 deletions
diff --git a/extras/HOME/.local/bin/set-backlight.sh b/extras/HOME/.local/bin/set-backlight.sh
new file mode 100755
index 0000000..d0b8e3b
--- /dev/null
+++ b/extras/HOME/.local/bin/set-backlight.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+frac="$1"
+
+if [[ "$frac" == -* ]] ; then
+ frac=${frac//-}
+ t='sub'
+elif [[ "$frac" == +* ]] ; then
+ frac=${frac//+}
+ t='add'
+else
+ t='abs'
+fi
+
+max="$(cat /sys/class/backlight/intel_backlight/max_brightness)"
+to_set="$(bc <<< "$max * $frac")"
+to_set=$(cut -d. -f1 <<< "$to_set") # Cut off the fractional part.
+
+if [[ "$t" == 'sub' ]] ; then
+ cur="$(cat /sys/class/backlight/intel_backlight/brightness)"
+ to_set=$((cur - to_set))
+elif [[ "$t" == 'add' ]] ; then
+ cur="$(cat /sys/class/backlight/intel_backlight/brightness)"
+ to_set=$((cur + to_set))
+fi
+
+if [ "$to_set" -gt "$max" ] ; then
+ to_set="$max"
+fi
+
+if [ "$to_set" -lt 0 ] ; then
+ to_set=0
+fi
+
+echo "$to_set" | tee /sys/class/backlight/intel_backlight/brightness
diff --git a/extras/HOME/.local/bin/spotify-control b/extras/HOME/.local/bin/spotify-control
index e001eb6..ac921c7 100755
--- a/extras/HOME/.local/bin/spotify-control
+++ b/extras/HOME/.local/bin/spotify-control
@@ -6,16 +6,17 @@ then
exit
fi
-if [ "$(pidof spotify)" = "" ]
+if [ "$(pidof spotifyd)" != "" ]
then
- echo "Spotify is not running"
- exit
+ target=spotifyd
+else
+ target=spotify
fi
function mpris2_dbus_player_do {
dbus-send \
--print-reply \
- --dest=org.mpris.MediaPlayer2.spotify \
+ --dest=org.mpris.MediaPlayer2."$target" \
/org/mpris/MediaPlayer2 \
"org.mpris.MediaPlayer2.Player.$1"
}
@@ -23,7 +24,7 @@ function mpris2_dbus_player_do {
function mpris2_dbus_get_player_property {
dbus-send \
--print-reply \
- --dest=org.mpris.MediaPlayer2.spotify \
+ --dest=org.mpris.MediaPlayer2."$target" \
/org/mpris/MediaPlayer2 \
org.freedesktop.DBus.Properties.Get \
string:'org.mpris.MediaPlayer2.Player' "string:$1"
@@ -31,11 +32,27 @@ function mpris2_dbus_get_player_property {
case $1 in
"play")
- mpris2_dbus_player_do PlayPause
+ status="$("$0" getStatus)"
+ if [[ "$target" == "spotifyd" ]] ; then
+ # Spotifyd doesn't support play/pause
+ if [[ "$status" == "Playing" ]] ; then
+ "$0" pause
+ else
+ "$0" justplay
+ fi
+ else
+ mpris2_dbus_player_do PlayPause
+ fi
;;
"next")
mpris2_dbus_player_do Next
;;
+ "pause")
+ mpris2_dbus_player_do Pause
+ ;;
+ "justplay")
+ mpris2_dbus_player_do Play
+ ;;
"prev")
mpris2_dbus_player_do Previous
;;
@@ -66,7 +83,7 @@ case $1 in
egrep -v ^$
;;
"getStatus")
- mpris_dbus_get_player_property 'PlaybackStatus' | \
+ mpris2_dbus_get_player_property 'PlaybackStatus' | \
grep 'string "[^"]*"' | \
sed 's/.*"\(.*\)"[^"]*$/\1/'
;;
diff --git a/extras/HOME/.xmobarrc b/extras/HOME/.xmobarrc
index a2b8a6e..8f17c72 100644
--- a/extras/HOME/.xmobarrc
+++ b/extras/HOME/.xmobarrc
@@ -14,8 +14,8 @@ Config
, borderWidth = 2
, bgColor = "#000000"
, fgColor = "white"
- , alpha = 220 -- default: 255
- , position = TopSize L 100 40
+ , alpha = 230 -- default: 255
+ , position = TopSize L 100 50
, textOffset = -1 -- default: -1
, iconOffset = -1 -- default: -1
, lowerOnStart = True
@@ -30,11 +30,11 @@ Config
, template =
" %logo% <fc=#a0a0a0><fn=3>%uname%</fn></fc><fc=#404040> │\
\</fc><fc=#a0a0a0> %date%</fc><fc=#404040> │ \
- \</fc>%StdinReader%}<fn=2><fc=#606060>%time%</fc></fn>\
+ \</fc>%StdinReader%}\
\{ %cpu% %memory% <fc=#404040>\
\│</fc> %weather% <fc=#404040>│\
\</fc> <fc=#a0a0a0>%mpris2%</fc> <fc=#404040>│ \
- \</fc>%bluetooth%%bat% "
+ \</fc>%bluetooth%%bat% <fc=#404040>│</fc> <fn=2><fc=#606060>%time%</fc></fn> "
, commands = [
Run StdinReader,
Run Date "%H:%M:%S" "time" 10,
@@ -57,7 +57,7 @@ Config
"--normal", "#88ff88",
"--high", "#ff8888"
] 10,
- Run Mpris2 "spotify" [
+ Run Mpris2 "spotifyd" [
"-t", "<fc=#1aa54b></fc> <fn=3><title></fn>",
"--nastring", "<fc=#404040> </fc>"] 20,
Run Com ".xmonad/xmobar-weather" [] "weather" 9000,
diff --git a/extras/HOME/.xmonad/xmobar-bluetooth b/extras/HOME/.xmonad/xmobar-bluetooth
index 30903e3..9b4f5cc 100755
--- a/extras/HOME/.xmonad/xmobar-bluetooth
+++ b/extras/HOME/.xmonad/xmobar-bluetooth
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
cur=""
diff --git a/extras/HOME/.xmonad/xmobar-weather b/extras/HOME/.xmonad/xmobar-weather
index e8ce28e..6b5c409 100755
--- a/extras/HOME/.xmonad/xmobar-weather
+++ b/extras/HOME/.xmonad/xmobar-weather
@@ -14,6 +14,11 @@ $content = `curl "https://api.sunrise-sunset.org/json?lat=$lat&lng=$lon&formatte
die "Unable to get sunrise/sunset data" unless defined $content;
+if (length($content) == 0) {
+ printf("<fc=#404040>X</fc>");
+ exit
+}
+
$sunrise_str=$content;
$sunset_str=$content;
$sunrise_str =~ s#.*"sunrise":"([^"]*)".*#\1#;