From 8e3d087d081c1a3a41c58f28564fc0fb98f923e8 Mon Sep 17 00:00:00 2001 From: Dominic Zimmer Date: Tue, 5 Nov 2019 22:08:19 +0100 Subject: [PATCH] Initial commit --- dm-bluetooth/dm-bluetooth.sh | 39 ++++++++++++++++++++++++ dm-recording/dm-recording.sh | 59 ++++++++++++++++++++++++++++++++++++ dm-steam/dm-steam.sh | 10 ++++++ 3 files changed, 108 insertions(+) create mode 100755 dm-bluetooth/dm-bluetooth.sh create mode 100755 dm-recording/dm-recording.sh create mode 100755 dm-steam/dm-steam.sh diff --git a/dm-bluetooth/dm-bluetooth.sh b/dm-bluetooth/dm-bluetooth.sh new file mode 100755 index 0000000..fa36115 --- /dev/null +++ b/dm-bluetooth/dm-bluetooth.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +option=$(echo -e "Restart Bluetooth\nManage Devices\nList connected devices" | dmenu -i -p "Do what?") +if [ "$option" == "Restart Bluetooth" ]; then + sudo systemctl restart bluetooth +fi +if [ "$option" == "Manage Devices" ]; then + device=$(echo "devices" | bluetoothctl | tail -n +4 | head -n -1 | cut -c 26- | dmenu -i) + if [ -n "$device" ]; then + mac=$(echo "devices" | bluetoothctl | grep "$device" | grep -v 'devices' | head -n +1 | cut -c 8-24) + option2=$(echo -e "Connect\nDisconnect\nReconnect\nRemove" | dmenu -i -p "$device ($mac)") + if [ "$option2" == "Disconnect" ]; then + echo "disconnect $mac" | bluetoothctl + fi + if [ "$option2" == "Reconnect" ]; then + echo "disconnect $mac" | bluetoothctl + sleep 2 + echo "connect $mac" | bluetoothctl + fi + if [ "$option2" == "Connect" ]; then + echo "connect $mac" | bluetoothctl + fi + if [ "$option2" == "Remove" ]; then + echo "remove $mac" | bluetoothctl + fi + fi +fi +if [ "$option" == "List connected devices" ]; then + IFS=$'\n' + for device in $(echo devices | bluetoothctl | tail -n +4 | head -n -1 | cut -c 26-); do + mac=$(echo "devices" | bluetoothctl | grep "$device" | grep -v 'devices' | head -n +1 | cut -c 8-24) + connected=$(echo "info $mac" | bluetoothctl | grep "Connected: yes" ) + echo "$device $connected" + if [ -n "$connected" ]; then + notify-send -i apps/bluetooth "$device" "is connected" + fi + unset connected + done +fi diff --git a/dm-recording/dm-recording.sh b/dm-recording/dm-recording.sh new file mode 100755 index 0000000..01822a9 --- /dev/null +++ b/dm-recording/dm-recording.sh @@ -0,0 +1,59 @@ +#!/bin/bash +if ! hash dmenu 2>/dev/null; then + notify-send "Error" "dmenu is not installed. Aborting." + echo "dmenu is not installed." + echo "Did you really try to run a dmenu utility without having dmenu installed?" + echo "Aborting." + exit 1 +fi +if ! hash ffmpeg 2>/dev/null; then + notify-send "Error" "ffmpeg is not installed.\n\nAborting." + echo "ffmpeg is not installed." + echo "Aborting." + exit 1 +fi +if ! ldconfig -p | grep libxcb >/dev/null; then + notify-send "Error" "libxcb is not installed.\n\nffmepg requires libxcb for it's x11grab option.\n\nAborting." + echo "libxcb is not installed." + echo "ffmepg requires libxcb for it's x11grab option." + echo "Aborting." + exit 1 +fi + +IFS=$'\n' +options="Fullscreen\nSelection" +choice=$(echo -e $options | sort | dmenu -p "Record" -i) + +if [ -z $choice ]; then + exit +fi + +case $choice in + "Fullscreen") + echo "Recording fullscreen" + file=$(mktemp -u /tmp/recording_XXXXXX.mp4) + notify-send --icon=panel/simplescreenrecorder-recording -t 900 'Recording starts' 'as soon as this notification closes' + sleep 1 + ffmpeg -f x11grab -framerate 20 -video_size 1366x768 -i :0.0 $file + notify-send --icon=panel/simplescreenrecorder-paused 'Recording stopped' + ln -sf $file /tmp/recording_latest.mp4 + ;; + + "Selection") + # need IFS = ' ' for read to be able to split the arguments + IFS=$' ' + echo "Recording region" + read -r x y w h <<< $(slop -f "%x %y %w %h" -q -l -c 0.3,0.4,0.6,0.4 ) + file=$(mktemp -u /tmp/recording_XXXXXX.mp4) + notify-send --icon=panel/simplescreenrecorder-recording -t 900 'Recording starts' 'as soon as this notification closes' + sleep 1 + ffmpeg -f x11grab -framerate 20 -show_region 1 -video_size "${w}x${h}" -i ":0.0+${x},${y}" $file + notify-send --icon=panel/simplescreenrecorder-paused 'Recording stopped' + ln -sf $file /tmp/recording_latest.mp4 + ;; + + *) + exit + ;; + +esac diff --git a/dm-steam/dm-steam.sh b/dm-steam/dm-steam.sh new file mode 100755 index 0000000..04589b6 --- /dev/null +++ b/dm-steam/dm-steam.sh @@ -0,0 +1,10 @@ +#!/bin/bash +IFS=$'\n' +games=$(cat /home/dominic/.steam/steam/steamapps/*.acf | grep "\"name\"" | cut -c 11- | rev | cut -c 2- | rev) +search=$(echo "$games" | sort | dmenu -i) +if [ -z $search ]; then + echo "nope" + exit +fi +appid=$(grep "$search" /home/dominic/.steam/steam/steamapps/*.acf | head -n 1 | sed 's/.*_//g' | sed -e 's/\.acf.*$//g' ) +steam steam://rungameid/$appid