init
Scripts meant to be called by keyboard shortcut
This commit is contained in:
commit
c4834e58b1
73
mediacontrol
Executable file
73
mediacontrol
Executable file
@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 2022 R. Branten
|
||||
# Updated 2024
|
||||
# ----
|
||||
# custom control shortcut file
|
||||
# start spotify in the brave browser and make it the first tab
|
||||
# ----
|
||||
# https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html
|
||||
|
||||
# check if spotify is active on the dbus
|
||||
BUS=$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep -i spotify | sed -r 's/ |string|[\"]//g')
|
||||
CONTROL="spotify"
|
||||
if [ -z "${BUS}" ]; then
|
||||
# spotify not active, check brave browser
|
||||
BUS=$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep -i brave | sed -r 's/ |string|[\"]//g')
|
||||
CONTROL="brave"
|
||||
fi
|
||||
|
||||
if [ -z "${BUS}" ]; then
|
||||
# spotify not active, check clementine
|
||||
BUS=$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep -i clementine | sed -r 's/ |string|[\"]//g')
|
||||
CONTROL="brave"
|
||||
fi
|
||||
|
||||
if [ -z "${BUS}" ]; then
|
||||
# nothing to control
|
||||
notify-send "Nothing to control"
|
||||
exit
|
||||
fi
|
||||
|
||||
# extract and set argument
|
||||
case $1 in
|
||||
pause)
|
||||
# for example space was pressed
|
||||
dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
|
||||
SENDNOTIFICATION=true
|
||||
;;
|
||||
next)
|
||||
# for example alt+Right was pressed
|
||||
dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
|
||||
SENDNOTIFICATION=true
|
||||
;;
|
||||
previous)
|
||||
# for example alt+Left was pressed
|
||||
SENDNOTIFICATION=true
|
||||
dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
|
||||
;;
|
||||
shuffle)
|
||||
# for example alt+s was pressed
|
||||
if [[ "$CONTROL" == "spotify" ]]; then
|
||||
notify-send "Shuffle on/off"
|
||||
SENDNOTIFICATION=false
|
||||
# not clear if shuffle is implemented yet, TESTED AS NOT WORKING
|
||||
dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Shuffle
|
||||
else
|
||||
notify-send "Shuffle not implemented"
|
||||
exit
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
# status can be: Playing, Paused or Stopped
|
||||
status=`dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$`
|
||||
artist=`dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$`
|
||||
album=`dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "album"|egrep -v "album"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
|
||||
title=`dbus-send --print-reply --dest=$BUS /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
|
||||
notify-send Media: "${status}\n${artist} - ${title}"
|
||||
|
||||
exit
|
||||
69
windowmanagement.sh
Executable file
69
windowmanagement.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 2022 R. Branten
|
||||
# ----
|
||||
# position windows
|
||||
# ----
|
||||
# get witdh of screen, not needed as percentages work just fine
|
||||
|
||||
# check if xdotool is installed
|
||||
if ! command -v xdotool &> /dev/null
|
||||
then
|
||||
notify-send WindowManagement: "xdotool not installed"
|
||||
exit
|
||||
fi
|
||||
|
||||
SCREENWIDTH=$(xdpyinfo | awk '/dimensions/{print $2}' | grep -oE ^[[:digit:]]\+)
|
||||
SCREENHEIGHT=$(xdpyinfo | awk '/dimensions/{print $2}' | grep -oE [[:digit:]]\+$)
|
||||
PANELHEIGHT=$(xdotool getwindowgeometry $(xdotool search --onlyvisible --class 'panel') | awk '/Geometry/{print $2}' | grep -oE [[:digit:]]\+$)
|
||||
HEIGHT=$SCREENHEIGHT-$PANELHEIGHT
|
||||
|
||||
# extract and set argument
|
||||
case $1 in
|
||||
center) # 100% window size centered
|
||||
WIDTH=100%
|
||||
HEIGHT=100%
|
||||
XPOS=0%
|
||||
;;
|
||||
center50) # 50% window size smack in the middle
|
||||
WIDTH=50%
|
||||
XPOS=25%
|
||||
;;
|
||||
left25) # 25% window size left side of screen
|
||||
WIDTH=25%
|
||||
XPOS=0%
|
||||
;;
|
||||
right25) # 25% window size right side of screen
|
||||
WIDTH=25%
|
||||
XPOS=75%
|
||||
;;
|
||||
left50) # 25% window size left side of screen
|
||||
WIDTH=50%
|
||||
XPOS=0%
|
||||
;;
|
||||
right50) # 25% window size right side of screen
|
||||
WIDTH=50%
|
||||
XPOS=50%
|
||||
;;
|
||||
centerleft25) # 25% window size left side of center screen
|
||||
WIDTH=25%
|
||||
XPOS=25%
|
||||
;;
|
||||
centerright25) # 25% window size right side of center screen
|
||||
WIDTH=25%
|
||||
XPOS=50%
|
||||
;;
|
||||
*)
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
# resize window
|
||||
#xdotool getactivewindow windowsize $WIDTH $HEIGHT
|
||||
xdotool getactivewindow windowsize $WIDTH 95%
|
||||
|
||||
# move window to location
|
||||
xdotool getactivewindow windowmove $XPOS 0.1
|
||||
|
||||
# display alert window
|
||||
notify-send WindowManagement: "${1}"
|
||||
Loading…
Reference in New Issue
Block a user