Stow scripts

This commit is contained in:
2023-11-25 09:35:34 -05:00
parent 547eb10705
commit b41a4141f2
41 changed files with 2 additions and 2 deletions

View File

@ -0,0 +1,11 @@
#! /bin/bash
# Load user settings from config file.
. ~/.config/settings.conf
for file in *.aax; do
convertedFile="./${file%%.*}.m4b"
if [ ! -f "$convertedFile" ]; then
ffmpeg -y -activation_bytes ${activation_bytes} -i ./${file} -codec copy $convertedFile
fi
done

159
scripts/bin/audio/aquamix.sh Executable file
View File

@ -0,0 +1,159 @@
#!/bin/bash
# Script to manuage audio mixing the the main audio interface.
# Import library
source $(dirname ${BASH_SOURCE[0]})/audio-lib.sh
INTERFACE_NAME='Clarett+ 8Pre'
INTERFACE_NUM=$(getCardNumber $INTERFACE_NAME)
checkCard "$INTERFACE_NAME" "$INTERFACE_NUM"
# Sets the volume levels of the first mono instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setMonoOne() {
setMono $INTERFACE_NUM 1 $1 $2 $3
}
# Sets the volume levels of the second mono instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setMonoTwo() {
setMono $INTERFACE_NUM 2 $1 $2 $3
}
# Sets the volume levels of the third mono instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setMonoThree() {
setMono $INTERFACE_NUM 3 $1 $2 $3
}
# Sets the volume levels of the first stereo instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setStereoOne() {
setStereo $INTERFACE_NUM 5 $1 $2 $3
}
# Sets the volume levels of the second stereo instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setStereoTwo() {
setStereo $INTERFACE_NUM 7 $1 $2 $3
}
# Sets the volume levels of the third stereo instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setStereoThree() {
setStereo $INTERFACE_NUM 9 $1 $2 $3
}
# Sets the volume levels of the fourth stereo instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setStereoFour() {
setStereo $INTERFACE_NUM 11 $1 $2 $3
}
# Sets the volume levels of the fifth stereo instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setStereoFive() {
setStereo $INTERFACE_NUM 13 $1 $2 $3
}
# Sets the volume levels of the sixth stereo instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setStereoSix() {
setStereo $INTERFACE_NUM 15 $1 $2 $3
}
# Sets the volume levels of the studio microphone.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setMic() {
setMono $INTERFACE_NUM 4 $1 $2 $3
}
# Sets the volume levels of the computer.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setComputerAudio() {
setStereo $INTERFACE_NUM 17 $1 $2 $3
}
# Sets the volume levels of all instrument.
#
# $1 monitor volume
# $2 first headphone volume
# $3 second headphone volume
function setInstruments() {
setMonoOne $1 $2 $3
setMonoTwo $1 $2 $3
setMonoThree $1 $2 $3
setStereoOne $1 $2 $3
setStereoTwo $1 $2 $3
setStereoThree $1 $2 $3
setStereoFour $1 $2 $3
setStereoFive $1 $2 $3
setStereoSix $1 $2 $3
}
function DAWMode() {
setInstruments $MUTE
setMic $MUTE
setComputerAudio $ZERO_DB
}
function NormalMode() {
setInstruments $ZERO_DB
setMic $MUTE
setComputerAudio $ZERO_DB
}
function PrintHelp() {
echo AquaMixer
echo '-h --help print out help options'
echo '-d --daw set interface to DAW mode'
echo '-n --normal set interface to normal mode'
exit 0
}
for var in "$@"; do
if [ $var == '-h' ] || [ $var == '--help' ]; then
PrintHelp
elif [ $var == '-d' ] || [ $var == '--daw' ]; then
DAWMode
elif [ $var == '-n' ] || [ $var == '--normal' ]; then
NormalMode
fi
done

View File

@ -0,0 +1,121 @@
# Mix names
MONITOR_LEFT='A'
MONITOR_RIGHT='B'
HEADPHONE_01_LEFT='C'
HEADPHONE_01_RIGHT='D'
HEADPHONE_02_LEFT='E'
HEADPHONE_02_RIGHT='F'
BLANK_LEFT="G"
BLANK_RIGHT='H'
# Level constants
MUTE='0'
ZERO_DB='0db'
# Formats a number to match the matrix numbering.
function formatMatrixNum() {
printf "%02d" $1
}
# Returns audio card number with matching card name.
function getCardNumber() {
echo $(cat /proc/asound/cards | grep -m 1 $1 | grep -Po '\d{1,2}' | head -1)
}
# Checks if the card exists and if not exits.
#
# $1 card name
# $2 card number
function checkCard() {
if [ -z "$2" ]; then
echo $1 not connected
exit 1
else
echo $1 found at hw:$2
fi
}
# Prints a list of all controls for the given sound card.
function printControls() {
amixer -c $1 controls
}
# Sets a mix to a level.
#
# $1 card number
# $2 matrix number
# $3 mix channel
function setMix() {
amixer -c $1 set "Mix $3 Input $(formatMatrixNum $2)" $4
}
# Sets the volume levels for a mono mix.
#
# $1 card number
# $2 matrix number
# $3 mix left channel
# $4 mix right channel
# $5 volume
function setMonoMix() {
setMix $1 $2 $3 $5
setMix $1 $2 $4 $5
}
# Sets the volume levels for a stereo mix.
#
# $1 card number
# $2 matrix number
# $3 mix left channel
# $4 mix right channel
# $5 volume
function setStereoMix() {
matrix=$2
setMix $1 $matrix $3 $5
setMix $1 $matrix $4 $MUTE
setMix $1 $((matrix+1)) $3 $MUTE
setMix $1 $((matrix+1)) $4 $5
}
# Sets the volume levels for a mono mix for several outputs.
#
# $1 card number
# $2 matrix number
# $3 mix left channel
# $4 mix right channel
# $5 monitor volume
# $6 first headphone volume
# $7 second headphone volume
function setMono() {
monitor=$3
headphone1=$4
headphone2=$5
if [ -n $headphone1 ]; then headphone1=$monitor; fi
if [ -n $headphone2 ]; then headphone2=$monitor; fi
setMonoMix $1 $2 $MONITOR_LEFT $MONITOR_RIGHT $monitor
setMonoMix $1 $2 $HEADPHONE_01_LEFT $HEADPHONE_01_RIGHT $headphone1
setMonoMix $1 $2 $HEADPHONE_02_LEFT $HEADPHONE_02_RIGHT $headphone2
setMonoMix $1 $2 $BLANK_LEFT $BLANK_RIGHT $MUTE
}
# Sets the volume levels for a stereo mix for several outputs.
#
# $1 card number
# $2 matrix number
# $3 mix left channel
# $4 mix right channel
# $5 monitor volume
# $6 first headphone volume
# $7 second headphone volume
function setStereo() {
monitor=$3
headphone1=$4
headphone2=$5
if [ -n $headphone1 ]; then headphone1=$monitor; fi
if [ -n $headphone2 ]; then headphone2=$monitor; fi
setStereoMix $1 $2 $MONITOR_LEFT $MONITOR_RIGHT $monitor
setStereoMix $1 $2 $HEADPHONE_01_LEFT $HEADPHONE_01_RIGHT $headphone1
setStereoMix $1 $2 $HEADPHONE_02_LEFT $HEADPHONE_02_RIGHT $headphone2
setStereoMix $1 $2 $BLANK_LEFT $BLANK_RIGHT $MUTE
}

11
scripts/bin/audio/es8start.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
# Script to add another audio interface if available.
DEVICE_NAME='ES-8'
DEVICE_NUM=$(getCardNumber $DEVICE_NAME)
checkCard $DEVICE_NAME $DEVICE_NUM
# Start up audio interface
alsa_in -d hw:$DEVICENUM -j "$DEVICENAME In" -q 1 &
alsa_out -d hw:$DEVICENUM -j "$DEVICENAME Out" -q 1 &

17
scripts/bin/audio/es9start.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# Script to add another audio interface if available.
# Import library
source $(dirname $(realpath ${BASH_SOURCE[0]}))/audio-lib.sh
DEVICE_NAME='ES-9'
DEVICE_NUM=$(getCardNumber $DEVICE_NAME)
checkCard $DEVICE_NAME $DEVICE_NUM
# Start up ES-5
pkill es-5-pipewire || true
/opt/es-5-pipewire/es-5-pipewire >/dev/null 2>/dev/null &
sleep 0.1
jack_connect ES-5:output "$DEVICE_NAME:playback_SL" || true
jack_connect ES-5:output "$DEVICE_NAME:playback_AUX6" || true

7
scripts/bin/audio/es9stop.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# Script to stop ES-9 audio interface
pkill alsa_in
pkill alsa_out
pkill es-5-pipewire

View File

@ -0,0 +1,15 @@
#!/usr/bin/env sh
# Script to bring up a prompt to set synth power state.
current='Keep current state'
off='Power synths off'
on='Power synths on'
selected=$(echo -e "${current}\n${off}\n${on}" | rofi -dmenu -p \
'Change synth power' -theme ~/.config/rofi/themes/aqua)
if [ "$selected" == "$off" ]; then
python ~/.config/scripts/audio/synth-power.py -o
elif [ "$selected" == "$on" ]; then
python ~/.config/scripts/audio/synth-power.py -d
fi

View File

@ -0,0 +1,63 @@
#!/usr/bin/env python3
# Program to control synthesizers power state.
import argparse
import configparser
import os,sys,inspect
currentDir = os.path.dirname(os.path.abspath(
inspect.getfile(inspect.currentframe())))
parentDir = os.path.dirname(currentDir)
sys.path.insert(0, parentDir)
from homeassistant import HomeAssistant
# Parse settings config
SCRIPT_DIR = os.path.abspath(os.path.dirname(sys.argv[0]))
configString = '[Settings]\n' + open(SCRIPT_DIR + '/../../settings.conf').read()
configParser = configparser.RawConfigParser()
configParser.read_string(configString)
# Load needed credentials
HA_IP = configParser.get('Settings', 'HA_IP')
HA_TOKEN = configParser.get('Settings', 'HA_TOKEN')
# Set power state of the Eurorack.
def setEurorackPower(state):
ha.setOnOff('switch.eurorack_lower', state)
ha.setOnOff('switch.eurorack_top', state)
# Set power state of the Behringer DeepMind 12.
def setDeepMind12Power(state):
ha.setOnOff('switch.deepmind_12', state)
# Set power state of the ASM Hydrasynth.
def setHydrasynthPower(state):
ha.setOnOff('switch.hydrasynth', state)
# Set power state of the Arturia MatrixBrute.
def setMatrixBrutePower(state):
ha.setOnOff('switch.matrixbrute', state)
# Set power state of all synthesizers.
def setSynthsPower(state):
setEurorackPower(state)
setDeepMind12Power(state)
setHydrasynthPower(state)
setMatrixBrutePower(state)
parser = argparse.ArgumentParser(
description='Control power state of synthesizers.')
parser.add_argument('-d', '--daw', action='store_true',
help='enable DAW mode',
dest='daw', default=False, required=False)
parser.add_argument('-o', '--off', action='store_true',
help='turn all synths off',
dest='off', default=False, required=False)
args = parser.parse_args()
ha = HomeAssistant(HA_IP, HA_TOKEN)
if args.daw:
setSynthsPower(True)
elif args.off:
setSynthsPower(False)

View File

@ -0,0 +1,89 @@
#! /bin/bash
# Kill Pulse.
function killPulse() {
systemctl --user stop pulseaudio.socket
systemctl --user stop pulseaudio.service
pulseaudio -k
killall pulseaudio
}
# Start Pulseaudio properly.
function fixPulse() {
PULSE="$(alsamixer 2>&1 | killall alsamixer)"
if [[ $PULSE == *'Connection refused'* ]]; then
echo 'Fixing Pulseaudio'
killPulse
sleep 0.1
pulseaudio -D
fixPulse
else
echo 'Pulseaudio is working correctly'
fi
}
# Start up programs that use audio.
function launchi3() {
if [ -z "$skipi3" ]; then
echo Opening i3wm sound workspaces
sleep .1 && i3-msg 'workspace 5; exec firefox'
sleep 5.1 && python ~/.config/scripts/start-firefox.py
fi
}
# Set up sinks.
function setupSinks() {
pactl set-default-sink speakers
pactl set-default-source sm7b
}
# Connect sinks to audio interface
function connectSinks() {
pw-link speakers:monitor_FL alsa_output.usb-Focusrite_Clarett__8Pre_00002325-00.pro-output-0:playback_AUX0
pw-link speakers:monitor_FR alsa_output.usb-Focusrite_Clarett__8Pre_00002325-00.pro-output-0:playback_AUX1
pw-link alsa_input.usb-Focusrite_Clarett__8Pre_00002325-00.pro-input-0:capture_AUX3 sm7b:input_FL
pw-link alsa_input.usb-Focusrite_Clarett__8Pre_00002325-00.pro-input-0:capture_AUX3 sm7b:input_FR
return $?
}
function renameInterface() {
for n in `seq 0 17` ; do
jack_property -p -s "alsa:pcm:2:hw:2,0:capture:capture_${n}" http://jackaudio.org/metadata/pretty-name "capture_$((n+1))"
done
for n in `seq 0 19` ; do
jack_property -p -s "alsa:pcm:2:hw:2,0:playback:playback_${n}" http://jackaudio.org/metadata/pretty-name "playback_$((n+1))"
done
for n in `seq 0 19` ; do
jack_property -p -s "alsa:pcm:2:hw:2,0:playback:monitor_${n}" http://jackaudio.org/metadata/pretty-name "monitor_$((n+1))"
done
}
# arg parser
for arg in "$@"
do
# Skip commands for i3wm
if [[ $arg == *"-s"* ]]; then
skipi3=true
fi
done
# Wire sinks
setupSinks
connectSinks
status=$?
while [[ $status -eq 0 ]]; do
echo "Connecting Sinks"
connectSinks
status=$?
sleep 1
done
# Rename Audio Devices
#renameInterface
# Eurorack audio interface
sh ~/.config/scripts/audio/es9start.sh
launchi3
systemctl --user restart polybar

10
scripts/bin/connect-nas.sh Executable file
View File

@ -0,0 +1,10 @@
#! /bin/bash
# Load user settings from config file.
. ~/.config/settings.conf
if nc -z $nasip 80 2>/dev/null; then
mount /mnt/share/lNAS
else
echo "$nasip is unreachable"
fi

View File

@ -0,0 +1,9 @@
#! /bin/bash
# Create backup directory
mkdir -p ./converted
# Convert files
for file in *.mp4 *.MP4 *.mov *.MOV; do
ffmpeg -i $file -acodec pcm_s16le -vcodec copy ./converted/${file%%.*}.mov
done

View File

@ -0,0 +1,19 @@
#!/usr/bin/env python3
import i3ipc, os
def onWindowClose(conn, win):
if(win.ipc_data['container']['window_properties']['class'] == 'Bitwig Studio'):
print(win.ipc_data['container']['window_properties']['title'])
if(win.ipc_data['container']['window_properties']['title'] !=
'DSP Performance Graph'):
os.system('sh ~/.config/scripts/audio/aquamix.sh -n')
os.system('sh ~/.config/scripts/audio/synth-power-prompt.sh')
i3 = i3ipc.Connection()
i3.on('window::close', onWindowClose)
i3.main()

View File

@ -0,0 +1,13 @@
#!/bin/bash
# Stop all polybar instances
killall -q polybar
while pgrep -x polybar >/dev/null; do sleep 0.1; done
for monitor in $(xrandr -q | grep -e "\sconnected\s" | cut -d' ' -f1); do
if [ $monitor == 'DP-2' ] || [ $monitor == 'LVDS-1' ]; then
MONITOR=$monitor polybar aqua &
fi
done

View File

@ -0,0 +1,7 @@
#!/bin/bash
# Stop all waybar instances
killall -q waybar
while pgrep -x waybar >/dev/null; do sleep 0.1; done
waybar &

View File

@ -0,0 +1,173 @@
#!/usr/bin/env python3
# Program to create a photo checklist of a given frc event.
import configparser
import datetime as dt
import re
import operator
import os
import sys
import tbapy
import todoist
# getProjectID() returns the project id that matches the name given.
def getProjectID(api, name):
for project in api.state['projects']:
if project['name'] == name:
return project['id']
print('Error: No project with the name {} found'.format(name))
exit(1)
# getChecklistName()
def getChecklistName(evemt):
return '{} Photos'.format(event['name'])
# getEventListID() returns the id of the checklist for the event and if there is none
# returns -1.
def getEventListID(items, event):
for item in items:
if item['content'] == getChecklistName(event):
return item['id']
return -1
# matchToTeamList() converts a match to two lists of teams
def matchToTeamList(match):
return match['alliances']['red']['team_keys'], match['alliances']['blue']['team_keys']
# createChecklistItem() creates a checklist item of the highest priority.
def createChecklistItem(name, api, projectID, item, date):
return api.items.add(name,
project_id=projectID,
parent_id=item['id'],
date_string=date,
priority=4)
# createPhotoChecklistItem() creates a checklist item that requires a photo.
def createPhotoChecklistItem(name, api, projectID, item, date):
return createChecklistItem('Take photo of **{}**'.format(name),
api, projectID, item, date)
# createPitList() creates a checklist for taking photos of a teams pit.
def createPitList(api, teams, projectID, checklist, date):
item = api.items.add('**Take** Pit Photos',
project_id=projectID,
parent_id=checklist['id'],
date_string=date,
priority=3)
for team in teams:
createChecklistItem('Pit photo of **{}** {}'.format(team['team_number'], team['nickname']),
api, projectID, item, date)
# createGroupsList() creates a checklist of the different groups of volenteers.
def createGroupsList(api, projectID, checklist, date):
item = api.items.add('Groups',
project_id=projectID,
parent_id=checklist['id'],
date_string=date,
priority=3)
groups = ['Judges', 'Robot Inspectors', 'Referees', 'Safety Inspectors',
'Field Reset', 'Queuers', 'CSAs', 'VC and Pit Admin']
for group in groups:
createPhotoChecklistItem(group, api, projectID, item, date)
# createWinnersList() creates a checklist of the winners of an event.
def createWinnersList(api, projectID, checklist, date):
item = api.items.add('Winners',
project_id=projectID,
parent_id=checklist['id'],
date_string=date,
priority=3)
groups = ['Chairman\'s award', 'Engineering Inspiration', 'Rookie All-Star', 'Winning Alliance',
'Winning Team 1', 'Winning Team 2', 'Winning Team 3']
for group in groups:
createPhotoChecklistItem(group, api, projectID, item, date)
# createRobotList() creates a checklist for taking photos of a team's robot.
def createRobotList(api, teams, projectID, checklist, date):
item = api.items.add('**Take** Robot Photos',
project_id=projectID,
parent_id=checklist['id'],
date_string=date,
priority=3)
for team in teams:
createChecklistItem('Robot photo of **{}** {}'.format(team['team_number'], team['nickname']),
api, projectID, item, date)
# Parse settings config
configString = '[Settings]\n' + open('../settings.conf').read()
configParser = configparser.RawConfigParser()
configParser.read_string(configString)
# Load needed credentials
tbaKey = configParser.get('Settings', 'TBAKey')
todoistToken = configParser.get('Settings', 'TodoistToken')
# Setup Todoist
api = todoist.TodoistAPI(todoistToken)
api.sync()
projectID = getProjectID(api, '🤖 Robotics')
items = api.state['items']
# Setup the Blue Alliance
tba = tbapy.TBA(tbaKey)
eventKey = sys.argv[1]
event = tba.event(eventKey)
setupDay = event['start_date']
day1 = (dt.datetime.strptime(setupDay, '%Y-%m-%d') + dt.timedelta(days=1)).strftime('%Y-%m-%d')
day2 = event['end_date']
teams = sorted(tba.event_teams(eventKey), key=operator.attrgetter('team_number'))
def firstMatch(team, matches):
for match in matches:
red, blue = matchToTeamList(match)
if team in red:
return match, 'red'
elif team in blue:
return match, 'blue'
return None, None
# Check if list already exists
eventListID = getEventListID(items, event)
if eventListID == -1:
# Create checklist
checklist = api.items.add(getChecklistName(event),
project_id=projectID,
date_string=day2,
priority=2)
# Setup
createPitList(api, teams, projectID, checklist, setupDay)
createChecklistItem('**Schedule** Judges photo', api, projectID, checklist, setupDay)
createChecklistItem('**Schedule** Inspectors photo', api, projectID, checklist, setupDay)
createChecklistItem('**Schedule** Seniors photo', api, projectID, checklist, setupDay)
createGroupsList(api, projectID, checklist, setupDay)
# Day 1
createPhotoChecklistItem('Guest Speakers', api, projectID, checklist, day1)
createRobotList(api, teams, projectID, checklist, day1)
# Day 2
createPhotoChecklistItem('Guest Speakers', api, projectID, checklist, day2)
createPhotoChecklistItem('Mentors after parade', api, projectID, checklist, day2)
createPhotoChecklistItem('Seniors', api, projectID, checklist, day2)
createPhotoChecklistItem('Alliances Representatives', api, projectID, checklist, day2)
createWinnersList(api, projectID, checklist, day2)
createChecklistItem('**Email** guest speakers and winners photos', api, projectID, checklist, day2)
else:
print('List already created')
matches = sorted(tba.event_matches(eventKey), key=operator.attrgetter('time'))
if not matches:
print('No match schedule yet')
else:
photoParentID = [item['id'] for item in items if 'parent_id' in item
and item['parent_id'] == eventListID
and 'Robot Photos' in item['content']][0]
robotPhotoList = [item for item in items if 'Robot photo of' in item['content']
and item['parent_id'] == photoParentID]
for robot in robotPhotoList:
if 'match' not in robot['content']:
team = 'frc{}'.format(re.findall(r'\d+', robot['content'])[0])
match, side = firstMatch(team, matches)
if match != None:
matchNumber = match['match_number']
matchTime = dt.datetime.fromtimestamp(match['time']).strftime('%Y-%m-%d %I:%M %p')
robot.update(date_string=matchTime, content='{} match {} {}'.format(robot['content'], matchNumber, side))
api.commit()

View File

@ -0,0 +1,11 @@
#! /bin/bash
mouseState=$(upower -i /org/freedesktop/UPower/devices/battery_hidpp_battery_0)
batteryPercentage=$(echo $mouseState | grep percentage | grep -Po '\d+%')
charging=$(echo $mouseState | grep 'state: charging')
if [ ! -z "$charging" ]; then
echo Charging
else
echo $batteryPercentage
fi

View File

@ -0,0 +1,142 @@
#!/usr/bin/env python3
# Python wrapper for REST API for Home Assistant.
from requests import get, post
import json
class HomeAssistant(object):
# Initalizes Home Assistant API wrapper.
def __init__(self, ip, token):
self.url = 'http://{}:8123'.format(ip)
self.headers = {
'Authorization': 'Bearer {}'.format(token),
'content-type': 'application/json',
}
# Sends post requests.
def postService(self, domain, service, data):
response = post("{}/api/services/{}/{}".format(self.url,
domain,
service),
headers=self.headers, data=json.dumps(data))
response.raise_for_status()
return response
# Sends get requests and turns requested data.
def getRequest(self, domain):
response = get("{}/api/{}".format(self.url, domain),
headers=self.headers)
return json.loads(response.text)
# Returns a message if the API is up and running.
def getAPI(self):
return self.getRequest('')
# Returns the current configuration
def getConfig(self):
return self.getRequest('config')
# Returns basic information about the Home Assistant instance.
def getDiscoveryInfo(self):
return self.getRequest('discovery_info')
# Returns an array of event objects. Each event object contains
# event name and listener count.
def getEvents(self):
return self.getRequest('events')
# Returns an array of service objects. Each object contains the
# domain and which services it contains.
def getServices(self):
return self.getRequest('services')
# Returns an array of state changes in the past. Each object contains
# further details for the entities.
def getHistory(self,
minimumResponse=False,
entityId='',
startTime='',
endTime='',
significantChangesOnly=False):
options=''
if startTime:
options = '/' + startTime
options += '?'
if endTime:
options += '&end_time=' + endTime
if minimumResponse:
options += '&minimal_response'
if entityId:
options += '&filter_entity_id=' + entityId
if significantChangesOnly:
options += '&significant_changes_only'
return self.getRequest('history/period'+options)
# Returns an array of logbook entries.
def getLogbook(self, entityId='', startTime='', endTime=''):
options=''
if startTime:
options = '/' + startTime
options += '?'
if endTime:
options += '&end_time=' + endTime
if entityId:
options += '&entity=' + entityId
return self.getRequest('logbook'+options)
# Returns an array of state objects or a state object for specified
# entity_id. Each state has the following attributes: entity_id, state,
# last_changed and attributes.
def getState(self, entityId=''):
if entityId:
entityId = '/' + entityId
return self.getRequest('states' + entityId)
# Retrieve all errors logged during the current session of Home Assistant.
def getErrorLog(self):
return self.getRequest('error_log')
# Returns the data (image) from the specified camera entity_id.
def getCameraProxy(self, entityId):
return self.getRequest('camera_proxy/' + entityId)
# Runs a Home Assistant scene.
def runScene(self, entityId):
data = {'entity_id': entityId}
self.postService('scene', 'turn_on', data)
# Runs a Home Assistant script.
def runScript(self, entityId):
data = {'entity_id': entityId}
self.postService('script', 'turn_on', data)
# Sets the brightness level of a device.
def setLevel(self, entityId, level):
data = {'entity_id': entityId, 'brightness_pct': level}
self.postService('homeassistant', 'turn_on', data)
# Turns a device off.
def turnOn(self, entityId):
data = {'entity_id': entityId}
self.postService('homeassistant', 'turn_on', data)
# Turns a device on.
def turnOff(self, entityId):
data = {'entity_id': entityId}
self.postService('homeassistant', 'turn_off', data)
# Turns a device of the given power state.
def setOnOff(self, entityId, power):
if power:
self.turnOn(entityId)
else:
self.turnOff(entityId)
# Toggles power state of a given device.
def togglePower(self, entityId):
if self.getState(entityId)['state'] == 'off':
self.turnOn(entityId)
else:
self.turnOff(entityId)

8
scripts/bin/hosts-file.sh Executable file
View File

@ -0,0 +1,8 @@
#! /bin/bash
if [[ $* == *-b* ]]; then
cp /etc/hosts ~/.config/.dotfiles/hosts
else
sudo cp ~/.config/.dotfiles/hosts /etc/hosts
fi

72
scripts/bin/i3-mouse.py Normal file
View File

@ -0,0 +1,72 @@
#!/usr/bin/env python3
import i3ipc
import sys
import os
import time
import pyautogui
from enum import Enum
# Enum for mouse direction
class Direction(Enum):
UP = 1
LEFT = 2
RIGHT = 3
DOWN = 4
NONE = 5
# getPoints() returns x and y movement of mouse
def getPoints():
sen = 10
t = 0
delay = 0.01
x,y = pyautogui.position()
while True:
time.sleep(delay)
t += delay
if t > 0.5:
return
xp, yp = pyautogui.position()
dx = x - xp
dy = y - yp
if abs(dx) > sen or abs(dy) > sen:
break
return dx, dy
#pointsToDirection() converts mouse movement points to a direction
def pointsToDirection(points):
if points is None:
return
x, y = points
if abs(x) > abs(y):
if x < 0:
return Direction.RIGHT
else:
return Direction.LEFT
else:
if y > 0:
return Direction.UP
else:
return Direction.DOWN
i3 = i3ipc.Connection()
focused = i3.get_tree().find_focused()
command = sys.argv[1]
if command in ['back', 'forward']:
if focused.window_instance not in ['overwatch.exe', 'hl2_linux']:
if sys.argv[1] == 'forward':
i3.command('workspace prev_on_output')
else:
i3.command('workspace next_on_output')
elif command == 'thumb':
direction = pointsToDirection(getPoints())
if direction == Direction.UP:
i3.command('move up')
elif direction == Direction.RIGHT:
i3.command('move right')
elif direction == Direction.DOWN:
i3.command('move down')
elif direction == Direction.LEFT:
i3.command('move left')

12
scripts/bin/i3wm-config-gen.sh Executable file
View File

@ -0,0 +1,12 @@
#! /bin/bash
# Load user settings from config file.
. ~/.config/settings.conf
cat ~/.config/i3/shared.conf ~/.config/i3/${computer}.conf > ~/.config/i3/config
if command -v i3-msg &> /dev/null; then
i3-msg reload
elif command -v swaymsg &> /dev/null; then
swaymsg reload
fi

View File

@ -0,0 +1,8 @@
#! /bin/bash
# A script to make creating i3wm window actions easier.
info=$(xprop)
title=$(echo "$info" | grep "WM_NAME(STRING)" | cut -d "\"" -f2 | cut -d "\"" -f1)
class=$(echo "$info" | grep "WM_CLASS(STRING)" | cut -d "\"" -f2 | cut -d "\"" -f1)
echo for_window [class=\"$class\" title=\"$title\"]

View File

@ -0,0 +1,27 @@
#! /bin/bash
# Automatic install script for Bitwig Studio
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
site='https://www.bitwig.com/download/'
bitwig=$(searchProgramInstalled bitwig-studio)
bitwigVersion=$(echo $bitwig | awk '{print $2;}'| filterVersion)
urlVersion=$(curl -sL $site | grep 'Bitwig Studio' | filterVersion | head -n 1)
url=https://downloads.bitwig.com/stable/$urlVersion/bitwig-studio-$urlVersion.deb
checkUptoDate Bitwig $bitwigVersion $urlVersion
echo Installing Bitwig Studio $urlVersion
# Setting up and downloading package
downloadPackage bitwig $url $(basename $url)
# Converting to Fedora friendly package
echo Creating rpm package
package=$(sudo alien -r $(basename $url) | awk '{print $1;}')
# Installing package
sudo rpm -Uvh --nodeps --force $package
sudo ln -s /usr/lib64/libbz2.so.1.0** /usr/lib64/libbz2.so.1.0

View File

@ -0,0 +1,49 @@
import json
import os
import re
import urllib.request
# getJSONData returns JSON data from Blackmagic Design's website.
def getJSONData():
with urllib.request.urlopen('https://www.blackmagicdesign.com/api/support/us/downloads.json') as url:
return json.loads(url.read().decode())
# getDownloads() returns a list of downloads.
def getDownloads():
return getJSONData()['downloads']
# getResolveStudioDownloads() returns a list of DaVinci Resolve Studio downlaods.
def getResolveStudioDownloads():
return [d for d in getDownloads() if 'davinci-resolve-and-fusion' in d['relatedFamilies'][0] and
'Studio' in d['name'] and 'Resolve' in d['name']]
# filterOnlyLinuxSupport() filters a list of downloads to only ones that
# support Linux.
def filterOnlyLinuxSupport(downloads):
return [d for d in downloads if 'Linux' in d['platforms']]
# getLinuxURL() returns the Linux download info.
def getLinuxURL(download):
return download['urls']['Linux'][0]
# getURLId() returns the download id.
def getURLId(url):
return url['downloadId']
# getURLVersion() returns the url version number.
def getURLVersion(url):
if 'Beta' in url['downloadTitle']:
beta = re.search('Beta \d+', url['downloadTitle'])
if beta:
beta = re.search('\d+', beta.group()).group()
else:
beta = '99'
return '{}.{}.{}.{}'.format(url['major'], url['minor'], url['releaseNum'], beta)
# getDownloadId() returns downlaod id hash.
def getDownloadId(download):
return download['id']
for d in filterOnlyLinuxSupport(getResolveStudioDownloads()):
linux = getLinuxURL(d)
print(getURLVersion(linux), getURLId(linux), getDownloadId(d))

View File

@ -0,0 +1,28 @@
#! /bin/bash
# Automatic install script for Dragonframe
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
dragonframe=$(searchProgramInstalled dragonframe | \
awk 'END {print $(NF-2), $(NF-1), $NF}')
dragonframeVersion=$(echo $dragonframe | awk '{print $2;}' | filterVersion)
url=$(curl -s https://www.dragonframe.com/downloads/ \
-A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" | \
grep .rpm | grep downloadButton | grep downloadButton | \
grep -io 'https://[a-z0-9+-._/]*.rpm' | head -n 1)
urlVersion=$(echo $url | awk -F "-" '{ print $2 }')
# Check if installed to the most recent version
checkUptoDate dragonframe $dragonframeVersion $urlVersion
echo Installing Dragonframe $urlVersion
# Setting up and downloading package
mkdir -p ~/Downloads/installers/dragonframe
cd ~/Downloads/installers/dragonframe
wget $url
# Install package
sudo dnf install $(basename "$url") -y

View File

@ -0,0 +1,62 @@
# Program version number comparison.
function versionGreater() {
if [[ $1 == $2 ]];then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++)); do
if [[ -z ${ver2[i]} ]]; then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]})); then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]})); then
return 2
fi
done
return 0
}
# Check if installed to the most recent version.
function checkUptoDate() {
if versionGreater $2 $3; then
echo $1 is up to date. Installed version $2 web version $3
exit
else
echo Updating $1 from $2 to $3...
fi
}
# Returns installed programs with a given name.
function searchProgramInstalled() {
dnf list -q | grep $1
}
# Filters string to Semantic Versioning.
function filterVersion() {
grep -Po -m 1 '\d{1,4}\.\d{1,4}\.*\d{0,4}'
}
# Downloads a file to the given download directory with
# the given name.
function downloadPackage() {
mkdir -p ~/Downloads/installers/${1}
cd ~/Downloads/installers/${1}
wget -O ${3} ${2}
}
# Get package manager
function packageManager() {
if command -v dnf &> /dev/null; then
echo dnf
elif command -v apt &> /dev/null; then
echo apt
fi
}

View File

@ -0,0 +1,25 @@
#! /bin/bash
# Automatic install script for KeeWeb password manager
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
keeweb=$(searchProgramInstalled KeeWeb)
keewebVersion=$(echo $keeweb | awk '{print $2;}' | filterVersion)
url=$(curl -s https://github.com/keeweb/keeweb/releases | grep .rpm | grep -Po '(?<=href=")[^"]*.rpm'| head -n 1)
url='https://github.com'$url
urlVersion=$(echo $url | filterVersion | head -n 1)
# Check if installed to the most recent version
checkUptoDate keeweb $keewebVersion $urlVersion
echo Installing KeeWeb $urlVersion
# Setting up and downloading package
mkdir -p ~/Downloads/installers/keeweb
cd ~/Downloads/installers/keeweb
wget $url
# Install package
sudo dnf install $(basename $url) -y

View File

@ -0,0 +1,26 @@
#! /bin/bash
# Automatic install script for Reaper
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
# Get download url
reaperVersion=$(head /opt/REAPER/whatsnew.txt | filterVersion)
reaperSite='https://www.reaper.fm/'
downloadPage=$(curl -s ${reaperSite}download.php)
urlVersion=$(echo "$downloadPage" | grep -A 2 'Linux x86_64' | filterVersion)
url=$reaperSite$(echo "$downloadPage" | grep linux_x86_64 | grep -Po '(?<=href=")[^"]*')
checkUptoDate Reaper $reaperVersion $urlVersion
# Setting up and downloading package
downloadPackage reaper $url $(basename $url)
# Install Reaper. Requires user input
tar -xf $(basename $url)
reaperDir=reaper_linux_x86_64
sudo sh ./$reaperDir/install-reaper.sh --install /opt --integrate-sys-desktop --usr-local-bin-symlink
# Delete extracted directory
rm -rd $reaperDir

View File

@ -0,0 +1,94 @@
#! /bin/bash
# Automatic install script for DaVinci Resolve
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
versionFile=/opt/resolve/version.txt
resolveVersion=$(cat /opt/resolve/docs/ReadMe.html | grep 'DaVinci Resolve Studio' | filterVersion)
url=$(python $(dirname ${BASH_SOURCE[0]})/blackmagic-parser.py | head -n 1)
urlVersion=$(echo $url | awk '{print $1;}')
downloadID=$(echo $url | awk '{print $2;}')
referId=$(echo $url | awk '{print $3;}')
# Check for beta
major=$(echo $urlVersion | cut -d. -f1)
minor=$(echo $urlVersion | cut -d. -f2)
micro=$(echo $urlVersion | cut -d. -f3)
beta=$(echo $urlVersion | cut -d. -f4)
if [ "$beta" == '99' ]; then
packageName="DaVinci_Resolve_Studio_${major}.${minor}"
elif [ -n "$beta" ]; then
packageName="DaVinci_Resolve_Studio_${major}.${minor}b${beta}"
else
packageName="DaVinci_Resolve_Studio_${urlVersion}"
fi
# Get version if beta installed
if [ -n $resolveVersion ]; then
resolveVersion=$(cat $versionFile)
fi
checkUptoDate Resolve $resolveVersion $urlVersion
downloadUrl="https://www.blackmagicdesign.com/api/register/us/download/${downloadID}"
useragent="User-Agent: Mozilla/5.0 (X11; Linux) \
AppleWebKit/537.36 (KHTML, like Gecko) \
Chrome/77.0.3865.75 \
Safari/537.36"
reqjson="{ \
\"firstname\": \"Fedora\", \
\"lastname\": \"Linux\", \
\"email\": \"user@getfedora.org\", \
\"phone\": \"919-555-7428\", \
\"country\": \"us\", \
\"state\": \"North Carolina\", \
\"city\": \"Raleigh\", \
\"product\": \"DaVinci Resolve\" \
}"
zipUrl="$(curl \
-s \
-H 'Host: www.blackmagicdesign.com' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Origin: https://www.blackmagicdesign.com' \
-H "$useragent" \
-H 'Content-Type: application/json;charset=UTF-8' \
-H "Referer: https://www.blackmagicdesign.com/support/download/${referId}/Linux" \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Authority: www.blackmagicdesign.com' \
-H 'Cookie: _ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294' \
--data-ascii "$reqjson" \
--compressed \
"$downloadUrl")"
# Setting up and downloading package
downloadPackage resolve $zipUrl "${packageName}.zip"
# Installing package
sudo dnf install libxcrypt-compat
unzip -o $packageName
installerName="DaVinci_Resolve_Studio_${major}.${minor}.${micro}"
if [ ! -f ./*${installerName}_Linux.run ]; then
installerName="${packageName}"
fi
echo "Installing ./*${installerName}_Linux.run"
chmod +x ./*${installerName}_Linux.run
sudo ./*${installerName}_Linux.run -i -y
# Version number backup
sudo echo $urlVersion > $versionFile
# Graphics card fix
sudo rm /etc/OpenCL/vendors/mesa.icd
sudo rm /etc/OpenCL/vendors/pocl.icd
# gLib fix
sudo mkdir /opt/resolve/libs/_disabled
sudo mv /opt/resolve/libs/libglib-2.0.so* /opt/resolve/libs/_disabled
# Keyboard mapping fix
setxkbmap -option 'caps:super'

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
sudo $(packageManager) install rust cargo

View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Automatic install script for SuperSlicer.
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
function desktopFile() {
echo 'Creating desktop file'
echo '[Desktop Entry]' > $1
echo "Name=${2}" >> $1
echo 'Comment=3D printing slicer' >> $1
echo "Exec=${3}" >> $1
echo 'Icon=' >> $1
echo 'Type=Application' >> $1
echo 'Terminal=false' >> $1
}
program='SuperSlicer'
programPath="${HOME}/.local/bin/${program}.AppImage"
programVersion=$($programPath --help | grep SuperSlicer | filterVersion)
url=$(curl -s https://api.github.com/repos/supermerill/SuperSlicer/releases)
urlVersion=$(echo $url | grep tag_name | filterVersion | head -n 1)
url=$(echo "$url" | grep browser_download | grep ubuntu | head -n 1 | \
tr -d '"'| awk '{print $2}')
# Check if installed to the most recent version
checkUptoDate $program $programVersion $urlVersion
echo Installing $program $urlVersion
# Setting up and downloading package
cd $(dirname $programPath)
rm $programPath
wget $url -O $program.AppImage
chmod +x $programPath
# Create desktop file
desktopPath="${HOME}/.local/share/applications/${program}.desktop"
if [ ! -f $desktopPath ]; then
desktopFile $desktopPath $program $programPath
fi

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
sudo $(packageManager) install sway waybar rofi mako alacritty

View File

@ -0,0 +1,38 @@
#! /bin/bash
# Automatic install script for yabridge an audio bridge for linux.
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
# Install wine if not already installed
if ! command -v wine &> /dev/null; then
if command -v dnf &> /dev/null; then
sudo dnf config-manager --add-repo \
https://dl.winehq.org/wine-builds/fedora/36/winehq.repo
fi
sudo $(packageManager) install winehq-staging
fi
program=yabridgectl
programVersion=$(yabridgectl --version | filterVersion)
url=$(curl -s https://api.github.com/repos/robbert-vdh/yabridge/releases | \
grep .tar.gz | grep releases/download | \
grep -Po 'https://[^"]*.tar.gz' | grep -v ubuntu | head -n 1)
urlVersion=$(echo $url | filterVersion | head -n 1)
# Check if installed to the most recent version
checkUptoDate $program $programVersion $urlVersion
echo Installing $program $urlVersion
# Setting up and downloading package
mkdir -p ~/Downloads/installers/${program}
cd ~/Downloads/installers/${program}
wget $url
# Install package
tar -xvzf *${urlVersion}.tar.gz
rm -rd ~/.local/share/yabridge
mv ./yabridge ~/.local/share/
sudo rm /bin/yabridgectl
sudo ln -s ~/.local/share/yabridge/yabridgectl /bin/yabridgectl

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Install and set zsh as the default shell.
# Import library
source $(dirname ${BASH_SOURCE[0]})/install-lib.sh
sudo $(packageManager) install zsh
chsh -s $(which zsh)

View File

@ -0,0 +1,30 @@
import datetime, holidays, os
from dateutil.tz import tzlocal
tz = tzlocal()
usHolidays = holidays.US()
def openToday(now = None):
if not now:
now = datetime.datetime.now(tz)
openTime = datetime.time(hour = 9, minute = 30, second = 0)
closeTime = datetime.time(hour = 16, minute = 0, second = 0)
# If it is a holiday
if now.strftime('%Y-%m-%d') in usHolidays:
return False
# If it is a weekend
if now.date().weekday() > 4:
return False
return True
def closed():
now = datetime.datetime.now(tz)
closeTime = datetime.time(hour = 16, minute = 0, second = 0)
# If before 0930 or after 1600
if (now.time() > closeTime):
return True
return False
if (openToday() and not closed()):
print("Open")
os.system("i3-msg 'workspace 10; exec firefox --new-window robinhood.com \
&& sleep 1 && firefox -new-tab app.webull.com/watch'")

33
scripts/bin/lock.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
# i3lock blurred screen inspired by /u/patopop007 and the blog post
# http://plankenau.com/blog/post-10/gaussianlock
# Timings are on an Intel i7-2630QM @ 2.00GHz
# Dependencies:
# imagemagick
# i3lock
# scrot (optional but default)
IMAGE=/tmp/i3lock.png
SCREENSHOT="scrot $IMAGE" # 0.46s
# Alternate screenshot method with imagemagick. NOTE: it is much slower
# SCREENSHOT="import -window root $IMAGE" # 1.35s
# Here are some imagemagick blur types
# Uncomment one to use, if you have multiple, the last one will be used
# All options are here: http://www.imagemagick.org/Usage/blur/#blur_args
BLURTYPE="0x5" # 7.52s
#BLURTYPE="0x2" # 4.39s
#BLURTYPE="5x2" # 3.80s
#BLURTYPE="2x8" # 2.90s
#BLURTYPE="2x3" # 2.92s
# Get the screenshot, add the blur and lock the screen with it
$SCREENSHOT
convert $IMAGE -blur $BLURTYPE $IMAGE
i3lock -i $IMAGE
rm $IMAGE

View File

@ -0,0 +1,85 @@
#!/usr/bin/env python3
from i3ipc import Connection, Event
import os, time
# moveWindowToWorkspace() moves a given window to a given workspace.
def moveWindowToWorkspace(window, workspace):
window.command('move window to workspace ' + workspace)
# getWindows() returns a list of all open windows on the desktop.
def getWindows(i3):
windows = []
for con in i3.get_tree():
if con.window and con.parent.type != 'dockarea':
windows.append(con)
return windows
# getWindowByName() returns a window with the given name.
def getWindowByName(name, windows):
for win in windows:
if name in win.name:
return win
return
# filterWindowsByClass() returns a filter list of windows by class.
def filterWindowsByClass(windowClass, windows):
return [w for w in windows if w.window_class == windowClass]
# doesWindowExist() returns if a given window exists.
def doesWindowExist(window):
return window != None
# switchWorkspace() switches currently selected workspace.
def switchWorkspace(workspace):
i3.command('workspace ' + workspace)
# execI3() runs a command from i3wm.
def execI3(program):
i3.command('exec ' + program)
# launchProgram() launches a program on a given workspace.
def launchProgram(program, workspace):
switchWorkspace(workspace)
execI3(program)
# isProgramRunning() returns if a program is running and if it is
# moves it to a given workspace.
def isProgramRunning(name, windows, workspace):
for n in name:
program = getWindowByName(n, windows)
if doesWindowExist(program):
moveWindowToWorkspace(program, workspace)
return True
return False
def isPagesLoaded(firefoxWindows):
for w in firefoxWindows:
if 'http' not in w.name:
return True
return True
i3 = Connection()
firefoxWindows = filterWindowsByClass('firefox', getWindows(i3))
while(not isPagesLoaded(firefoxWindows)):
time.sleep(0.1)
switchWorkspace('10')
switchWorkspace('1')
# Music
if not isProgramRunning(['music.youtube.com'], firefoxWindows, '10'):
launchProgram('firefox --new-window music.youtube.com', '10')
# Stocks
if not isProgramRunning(['Robinhood', 'Webull'], firefoxWindows, '10'):
os.system('python ~/.config/scripts/launch-stocks-tracker.py')
# Videos
if not isProgramRunning(['odysee.com', 'lbry.tv', 'www.youtube.com',
' - YouTube', 'hulu.com', 'netflix.com',
'disneyplus.com', 'tv.youtube.com'],
firefoxWindows, '10'):
launchProgram('firefox --new-window youtube.com/feed/subscriptions', '10')
launchProgram('sleep 1 && firefox -new-tab odysee.com/$/following', '10')

17
scripts/bin/toggle-graphics.sh Executable file
View File

@ -0,0 +1,17 @@
#! /bin/bash
# Script to toggle graphical
defTarget=$(systemctl get-default)
if [[ $defTarget == 'graphical.target' ]]
then
echo 'Changing default target to nongraphical shell'
sudo systemctl set-default multi-user.target
else
echo 'Changing default target to graphical shell'
sudo systemctl set-default graphical.target
fi
echo
echo 'Default target changed to '$(systemctl get-default)
echo 'Please reboot for the change to take effect'

33
scripts/bin/trackpad-toggle.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
# Get device id of Synaptics TrackPad
id=$(xinput list --id-only 'SynPS/2 Synaptics TouchPad')
# Enables TrackPad
trackpadEnable() {
xinput set-prop $id "Device Enabled" 1
exit
}
# Disables TrackPad
trackpadDisable() {
xinput set-prop $id "Device Enabled" 0
exit
}
# Checks for disable flag
if [ ! -z $1 ] && [ $1 == '-d' ]; then
echo flag worked
trackpadDisable
fi
# Convert to an arry
read -a trackPadState <<< "$(xinput --list-props $id | grep "Device Enabled")"
devEnabled=${devString_array[3]}
# Flip the state of the TrackPad
if [ ${trackPadState[3]} -eq 1 ]; then
trackpadDisable
else
trackpadEnable
fi

57
scripts/bin/update.sh Executable file
View File

@ -0,0 +1,57 @@
#! /bin/bash
# This script is a catch all program updater.
# DNF Updater
function dnfUpdate {
if command -v dnf &> /dev/null; then
echo Updating DNF...
sudo dnf update #--exclude=wine*
fi
}
# Apt Updater
function aptUpdate {
if command -v apt &> /dev/null; then
echo Updating APT...
sudo apt update
sudo apt upgrade
fi
}
# Flatpack Updater
function flatpakUpdate {
if command -v flatpak &> /dev/null; then
echo Updating Flatpak...
flatpak uninstall --unused
flatpak update
fi
}
# Checks if a program is installed and if it is runs an updater script
function updateProgram {
if command -v $1 &> /dev/null; then
sh $2
fi
}
# Manually installed programs updater
function manualUpdate {
if command -v dnf &> /dev/null; then
echo Updating manually installed programs...
updateProgram bitwig-studio ~/.config/scripts/installers/bitwig-install.sh &
updateProgram /opt/dragonframe5/bin/Dragonframe ~/.config/scripts/installers/dragonframe-install.sh &
updateProgram reaper ~/.config/scripts/installers/reaper-install.sh &
updateProgram /opt/resolve/bin/resolve ~/.config/scripts/installers/resolve-install.sh &
updateProgram /opt/keeweb/keeweb ~/.config/scripts/installers/keeweb-install.sh &
updateProgram yabridgectl ~/.config/scripts/installers/yabridge-install.sh &
wait
fi
}
dnfUpdate
aptUpdate
echo ''
flatpakUpdate
echo ''
manualUpdate

53
scripts/bin/video/cr3todng.sh Executable file
View File

@ -0,0 +1,53 @@
#! /bin/bash
# Script to convert CR3 files to DNG.
WINE_PREFIX=$(echo $HOME/.dng-wine)
CONVERTER_PATH='C:\Program Files\Adobe\Adobe DNG Converter\Adobe DNG Converter.exe'
FLAGS='-c -fl -p1'
# Converts foreward slashes to back slashes.
function foreward2Back() {
sed 's:/:\\:g'
}
# Converts a directory path a wine friendly path.
function dir2Wine() {
echo 'z:'"$(echo $( cd "$1" >/dev/null 2>&1 ; pwd -P ) | foreward2Back)"
}
# Converts file path to a wine friendly path to the file.
function file2Wine() {
echo $(dir2Wine $(dirname $1))\\$(basename $1)
}
# Converts a CR3 RAW file to DNG RAW.
function convertFile() {
WINEPREFIX="$WINE_PREFIX" wine "$CONVERTER_PATH" \
$FLAGS $2 "$(file2Wine $1)" &
}
# Converts all CR3 RAW files in a directory to DNG RAW.
function convertDir() {
for file in $1*.cr3; do
convertFile $file "-d $2"
done
}
start=`date +%s%N`
src=$1
dst=$(dir2Wine $2)
if [[ -d $src ]]; then
convertDir $src $dst
elif [[ -f $src ]]; then
convertFile $src $dst
else
echo "$src is not valid"
exit 1
fi
wait
end=`date +%s%N`
echo Execution time was `expr $end - $start` nanoseconds.