Clean up i3 scripts
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$1" ]] ; then
|
||||
modules="$1"
|
||||
else
|
||||
modules=all
|
||||
fi
|
||||
|
||||
py3-cmd refresh "$modules"
|
||||
@@ -1,137 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# name of the sink. execute pactl list sinks to get a list
|
||||
SINKNAME="$(pactl info | grep '^Default Sink:' | cut -d ' ' -f 3-)"
|
||||
|
||||
# name of the sink. execute pactl list sinks to get a list
|
||||
SOURCENAME="$(pactl info | grep '^Default Source:' | cut -d ' ' -f 3-)"
|
||||
|
||||
#SINKNAME="alsa_output.usb-Logitech_Logitech_Wireless_Headset_88C626354D45-00.analog-stereo"
|
||||
# this is the worst
|
||||
SINK=$(( $(pactl list sinks | grep "Name: " | grep -n "${SINKNAME}"$ | grep -o "^[[:digit:]]*") -1))
|
||||
|
||||
SOURCE=$(( $(pactl list sources | grep "Name: " | grep -n "${SOURCENAME}"$ | grep -o "^[[:digit:]]*") -1))
|
||||
|
||||
|
||||
getvol() {
|
||||
echo $(pactl list sinks | grep "^[[:space:]]*Volume" | head -n $(( $SINK + 1 )) | tail -n 1 | grep -o "[[:digit:]]*%" | head -n 1 | cut -d "%" -f 1)
|
||||
}
|
||||
|
||||
setvol() {
|
||||
if [[ $1 =~ [+-][0-9]+ ]] ; then
|
||||
oldvol="$(getvol)"
|
||||
echo "oldvol $oldvol"
|
||||
delta="$(echo "$1" | cut -c 2-)"
|
||||
echo "delta $delta"
|
||||
if [[ "$(echo "$1" | cut -c 1)" == "+" ]] ; then
|
||||
echo "+"
|
||||
newvol=$(( $oldvol + $delta ))
|
||||
else
|
||||
echo "-"
|
||||
newvol=$(( $oldvol - $delta ))
|
||||
echo $newvol
|
||||
fi
|
||||
if [[ $newvol -gt 100 ]]; then
|
||||
echo "capping at 100 percent"
|
||||
newvol=100
|
||||
fi
|
||||
if [[ $newvol -lt 0 ]]; then
|
||||
echo "capping at 0 percent"
|
||||
newvol=0
|
||||
fi
|
||||
echo "newvol $newvol"
|
||||
else
|
||||
newvol="$1"
|
||||
fi
|
||||
pactl set-sink-volume $SINKNAME $(( $newvol * 65536 / 100 ))
|
||||
}
|
||||
|
||||
ismuted() {
|
||||
muted=$(pactl list sinks | grep "^[[:space:]]*Mute" | head -n $(( $SINK + 1 )) | tail -n 1 | cut -d " " -f 2)
|
||||
if [[ $muted == "no" ]]; then
|
||||
echo 0
|
||||
else
|
||||
echo 1
|
||||
fi
|
||||
}
|
||||
|
||||
mute() {
|
||||
pactl set-sink-mute $SINKNAME 1
|
||||
}
|
||||
|
||||
unmute() {
|
||||
pactl set-sink-mute $SINKNAME 0
|
||||
}
|
||||
|
||||
mute-toggle() {
|
||||
pactl set-sink-mute $SINKNAME toggle
|
||||
}
|
||||
|
||||
mute-toggle-mic() {
|
||||
pactl set-source-mute $SOURCENAME toggle
|
||||
}
|
||||
|
||||
status() {
|
||||
if [[ $(ismuted) == "1" ]] ; then
|
||||
echo "mute"
|
||||
return
|
||||
fi
|
||||
echo "$(getvol)%"
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage:"
|
||||
echo
|
||||
echo "$0 get-vol"
|
||||
echo "$0 set-vol VOL_PERC"
|
||||
}
|
||||
|
||||
update_status_bar_sink() {
|
||||
~/.i3/scripts/bar-update "volume_status output"
|
||||
}
|
||||
|
||||
update_status_bar_source() {
|
||||
~/.i3/scripts/bar-update "volume_status input"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"sink")
|
||||
echo $SINKNAME
|
||||
echo $SINK
|
||||
;;
|
||||
"get-vol")
|
||||
echo $(getvol)
|
||||
;;
|
||||
"set-vol")
|
||||
if [[ -z "$2" ]] ; then
|
||||
usage
|
||||
else
|
||||
setvol "$2"
|
||||
fi
|
||||
update_status_bar_sink
|
||||
;;
|
||||
"mute")
|
||||
mute
|
||||
update_status_bar_sink
|
||||
;;
|
||||
"unmute")
|
||||
unmute
|
||||
update_status_bar_sink
|
||||
;;
|
||||
"mute-toggle")
|
||||
mute-toggle
|
||||
update_status_bar_sink
|
||||
;;
|
||||
"mute-toggle-mic")
|
||||
mute-toggle-mic
|
||||
update_status_bar_source
|
||||
;;
|
||||
"is-muted")
|
||||
echo $(ismuted)
|
||||
;;
|
||||
"status")
|
||||
echo $(status)
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
esac
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_status_file="${XDG_RUNTIME_DIR}/presentation-mode-on"
|
||||
_autostart="$HOME/.autostart.sh"
|
||||
|
||||
is_on() {
|
||||
[[ -e "${_status_file}" ]]
|
||||
@@ -12,9 +11,6 @@ switch_on() {
|
||||
dunstctl set-paused true &
|
||||
systemctl --user --no-block stop redshift.service
|
||||
systemctl --user --no-block stop spotify.service
|
||||
~/.i3/scripts/bar-update "external_script presentation_mode"
|
||||
~/.i3/scripts/bar-update "systemd redshift"
|
||||
~/.i3/scripts/bar-update "systemd spotify"
|
||||
}
|
||||
|
||||
switch_off() {
|
||||
@@ -22,9 +18,6 @@ switch_off() {
|
||||
dunstctl set-paused false &
|
||||
systemctl --user --no-block start redshift.service
|
||||
systemctl --user --no-block start spotify.service
|
||||
~/.i3/scripts/bar-update "external_script presentation_mode"
|
||||
~/.i3/scripts/bar-update "systemd redshift"
|
||||
~/.i3/scripts/bar-update "systemd spotify"
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +25,8 @@ case "$1" in
|
||||
status)
|
||||
if is_on ; then
|
||||
printf "on\n"
|
||||
printf '#F4BF75'
|
||||
else
|
||||
printf "off\n"
|
||||
# printf '#F4BF75'
|
||||
fi
|
||||
;;
|
||||
toggle)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
case "$1" in
|
||||
toggle)
|
||||
cmd="play-pause"
|
||||
;;
|
||||
next)
|
||||
cmd="next"
|
||||
;;
|
||||
previous)
|
||||
cmd="previous"
|
||||
;;
|
||||
*)
|
||||
echo "wrong argument $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
playerctl -p spotify "${cmd}"
|
||||
~/.i3/scripts/bar-update spotify
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import dbus
|
||||
session_bus = dbus.SessionBus()
|
||||
spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify",
|
||||
"/org/mpris/MediaPlayer2")
|
||||
spotify_properties = dbus.Interface(spotify_bus,
|
||||
"org.freedesktop.DBus.Properties")
|
||||
metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
|
||||
|
||||
# The property Metadata behaves like a python dict
|
||||
# for key, value in metadata.items():
|
||||
# print(key, value)
|
||||
|
||||
# To just print the title
|
||||
print("{}: {} - [{}]".format(
|
||||
metadata['xesam:artist'][0],
|
||||
metadata['xesam:title'],
|
||||
metadata['xesam:album']
|
||||
))
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
app="${1:?app missing}"
|
||||
|
||||
unitname="${app}.service"
|
||||
|
||||
running() {
|
||||
systemctl --user --quiet status "${unitname}" >/dev/null
|
||||
}
|
||||
|
||||
if running ; then
|
||||
systemctl --user stop "${unitname}"
|
||||
else
|
||||
systemctl --user start "${unitname}"
|
||||
fi
|
||||
|
||||
py3-cmd refresh "systemd $app"
|
||||
Reference in New Issue
Block a user