Skip to content

Instantly share code, notes, and snippets.

View BenJuan26's full-sized avatar

Benjamin Schubert BenJuan26

  • Qlik
  • Toronto
View GitHub Profile
#!/bin/bash
SCHEMA="com.benjuan26.soundswitch"
KEY=device
CURRENT_DEVICE=$(gsettings get ${SCHEMA} ${KEY})
if [ "$CURRENT_DEVICE" = "'analog-output-lineout'" ]; then
echo "first one"
gsettings set ${SCHEMA} ${KEY} "analog-output-headphones"
else
const Applet = imports.ui.applet;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const settingsSchemaId = 'com.benjuan26.soundswitch';
const settingsKey = 'device';
const notificationDuration = '2000';
const notificationTitle = 'Sound Switch';
function oppositeDevice(currentDevice) {
<schemalist>
<schema id="com.benjuan26.soundswitch" path="/com/benjuan26/soundswitch/">
<key type="s" name="device">
<default>"analog-output-lineout"</default>
<summary>The current audio output device</summary>
<description/>
</key>
</schema>
</schemalist>
const Applet = imports.ui.applet;
const GLib = imports.gi.GLib;
function run(cmd) {
try {
let [result, stdout, stderr] = GLib.spawn_command_line_sync(cmd);
if (stdout !== null) {
return stdout.toString();
}
} catch (error) {
@BenJuan26
BenJuan26 / sound-switch-simple.sh
Last active October 27, 2019 21:59
A simple bash script to switch between audio device sinks
#!/bin/bash
CURRENT_PROFILE=$(pactl list sinks | grep "Active Port" | cut -d ' ' -f 3-)
NOTIFICATION_DURATION_MS=2000
notify() {
notify-send --hint=int:transient:1 -t $NOTIFICATION_DURATION_MS "Sound Switch" "$1"
}
amixer -c0 set "Auto-Mute Mode" Disabled