summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-09-02 23:34:01 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2024-09-02 23:34:01 -0400
commit43dbb32d741e11f8e06341f515944ec757d4578f (patch)
treec100c1a137e1668aa725ce6c0a94794f37b6a1c2 /.local
parent21bd4aae35ab8b3bd10216f76417567086c78abf (diff)
Lot's of stuffHEADmaster
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/backlightctl52
-rwxr-xr-x.local/bin/makewall45
-rw-r--r--.local/share/applications/lynx.desktop8
3 files changed, 59 insertions, 46 deletions
diff --git a/.local/bin/backlightctl b/.local/bin/backlightctl
index 1d38c07..453c3c0 100755
--- a/.local/bin/backlightctl
+++ b/.local/bin/backlightctl
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Get the correct sub-directory for your backlight device
root_path="/sys/class/backlight/"
@@ -12,26 +12,26 @@ default_step=10
default_set=50
to_percent() {
- printf "%d" "$((100 * $1 / $max))"
+ printf "%d" "$((100 * $1 / $max))"
}
to_value() {
- printf "%d" "$((max * $1 / 100))"
+ printf "%d" "$((max * $1 / 100))"
}
get_status() {
- cat "$device/brightness"
+ cat "$device/brightness"
}
get_percent() {
- to_percent "$(get_status)"
+ to_percent "$(get_status)"
}
# Add $1 to current brightness. Adjust if out of bounds (0-$max)
# $1 is converted to a value between 0-$max within this function
get_total() {
- value="$(to_value "$1")"
- printf "%d" "$(($(get_status) + $value))"
+ value="$(to_value "$1")"
+ printf "%d" "$(($(get_status) + $value))"
}
helpmsg="Usage: backlightctl -[FLAG] [PERCENTAGE]
@@ -46,38 +46,38 @@ helpmsg="Usage: backlightctl -[FLAG] [PERCENTAGE]
case "$1" in
-i | --increase)
- [ -z "$2" ] && step="$default_step" || step="$2"
- get_total "$step" >"$device/brightness"
- ;;
+ [ -z "$2" ] && step="$default_step" || step="$2"
+ get_total "$step" >"$device/brightness"
+ ;;
-d | --decrease)
- [ -z "$2" ] && step="$default_step" || step="$2"
- get_total "-$step" >"$device/brightness"
- ;;
+ [ -z "$2" ] && step="$default_step" || step="$2"
+ get_total "-$step" >"$device/brightness"
+ ;;
-s | --set)
- [ -z "$2" ] && set="$default_set" || set="$2"
- to_value "$set" >"$device/brightness"
- ;;
+ [ -z "$2" ] && set="$default_set" || set="$2"
+ to_value "$set" >"$device/brightness"
+ ;;
-g | --get)
- printf "󰃠 %s\n" "$(get_status)%"
- ;;
+ printf "󰃠 %s\n" "$(get_status)%"
+ ;;
-h | --help)
- printf "%s" "$helpmsg"
- ;;
+ printf "%s" "$helpmsg"
+ ;;
*)
- printf "\033[31mInvalid option: $1\033[0m\n%s" "$helpmsg" && exit 1
- ;;
+ printf "\033[31mInvalid option: $1\033[0m\n%s" "$helpmsg" && exit 1
+ ;;
esac
# Send notification
case "$@" in
*-q* | *--quiet*)
- exit 0
- ;;
+ exit 0
+ ;;
*)
- notify-send.sh -t 1000 --replace-file /tmp/bl-notif -a "󰃠 Brightness:" "$(get_percent)%"
- ;;
+ notify-send.sh -t 1000 --replace-file /tmp/bl-notif -a "󰃠 Brightness:" "$(get_percent)%"
+ ;;
esac
diff --git a/.local/bin/makewall b/.local/bin/makewall
index 614d030..3458676 100755
--- a/.local/bin/makewall
+++ b/.local/bin/makewall
@@ -2,29 +2,34 @@
wallDir="${XDG_CONFIG_HOME:-$HOME}/wallpapers"
-# Acquire the list of connected displays
-displays="$(wlr-randr --json | jq -r '.[] | select(.enabled) | .name')"
+# Acquire the list of connected displays and their models
+displays="$(wlr-randr --json | jq -r '.[] | select(.enabled) | "\(.name) \(.model)"')"
echo "$displays"
-# If there is a wallpaper with a filename matching the display
-# name, set it as the wallpaper for that display.
-# ex: DP-1.jpg and DP-1.png are both valid filenames
-# Otherwise, set the wallpaper to the default wallpaper
-# (default.png or default.jpg)
+# Sanitize the model names by replacing spaces with hyphens
+sanitize_model() {
+ echo "$1" | sed 's/\s/-/g'
+}
+
+# If there is a wallpaper with a filename matching the display name or sanitized model,
+# set it as the wallpaper for that display.
setDisplay() {
- case $(ls $wallDir) in
- *"$1"*)
- wall=$(ls $wallDir | grep "$1" | head -n 1)
- ;;
- *)
- wall=$(ls $wallDir | grep "default" | head -n 1)
- ;;
- esac
- swaybg --output $1 -m fill --image $wallDir/$wall &
+ name="$1"
+ model="$2"
+ case $(ls $wallDir) in
+ *"$name"*|*"$model"*)
+ wall=$(ls $wallDir | grep -E "$name|$model" | head -n 1)
+ ;;
+ *)
+ wall=$(ls $wallDir | grep "default" | head -n 1)
+ ;;
+ esac
+ swaybg --output "$name" -m fill --image "$wallDir/$wall" &
}
# Set the wallpaper for each display
-killall swaybg > /dev/null 2>&1
-for display in $displays; do
- setDisplay $display
-done
+killall swaybg >/dev/null 2>&1
+while IFS=' ' read -r name model; do
+ sanitized_model=$(sanitize_model "$model")
+ setDisplay "$name" "$sanitized_model"
+done <<< "$displays"
diff --git a/.local/share/applications/lynx.desktop b/.local/share/applications/lynx.desktop
new file mode 100644
index 0000000..d89da4f
--- /dev/null
+++ b/.local/share/applications/lynx.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=Lynx Web Browser
+Comment=Text-based web browser
+Exec=/usr/bin/foot -e w3m -sixel %u
+Categories=Network;WebBrowser;
+MimeType=text/html;
+Icon=utilities-terminal