Skip to content

Instantly share code, notes, and snippets.

View bonelifer's full-sized avatar

William Jacoby bonelifer

View GitHub Profile
@emmaly
emmaly / gist:8267078
Created January 5, 2014 11:21
Bash script to automatically switch PulseAudio sink to Bluetooth headset on connect with A2DP profile and 50% volume.
#!/bin/bash
sink_name="bluez_sink.00_42_1B_AD_FA_CE"
if [ -z "$1" ]; then
dbus-monitor --system "path=/org/bluez/777/hci0/dev_00_42_1B_AD_FA_CE, interface=org.bluez.AudioSink, member=Connected" | while read line; do
echo $line
$0 1
done
else
@abdullahkhalids
abdullahkhalids / pipewire-bluetooth-headphone-manager
Created March 9, 2022 16:09
A bash script that helps reliably connect to bluetooth headphones. Just bind the three possible inputs to different keyboard shortcuts.
#!/bin/bash
#sudo systemctl start bluetooth.service
connect() {
bluetoothstatus=`bluetooth | cut -c 13-`
if [ "$bluetoothstatus" == "off" ]; then
bluetooth on
#IMPORTANT
sudo apt update &&
sudo apt install -y software-properties-common curl wget pavucontrol #pavucontrol is for audio configs
#Themes and Tweak (Ubuntu)
sudo add-apt-repository ppa:numix/ppa
sudo apt update
sudo apt install -y numix-gtk-theme numix-icon-theme-circle
sudo apt install -y unity-tweak-tool gnome-tweak-tool
#!/usr/bin/bash
# ------------------------------------------------------------------------------
# [INFO]
# If you are not registered as sudoers, you will be asked for your password.
# ------------------------------------------------------------------------------
echo "🚀 A setup scripts for Ubuntu Desktop 22.04 LTS."
# ------------------------------------------------------------------------------

Sync stuff automatically once it’s plugged in

This strategy worked for me: https://www.pcsuggest.com/run-shell-scripts-from-udev-rules/

The contents of /etc/udev/rules.d/phone-plugin.rules follow.

# The following is killed as the documentation explains about `RUN'
# ACTION=="add",ATTRS{idVendor}=="04e8",ATTRS{idProduct}=="6860",RUN+="/bin/su oney -c /home/oney/bin/.sync_phone.sh | at now"
# The service activated is a USER service, so the following doesn't work
# ACTION=="add",ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="6860",TAG+="systemd",ENV{SYSTEMD_WANTS}="sync-phone.service" 
# The following rule works just right :)

I wanted to do an automatic sync of a directory in my hard drive with 1 directory in my mp3 player (MSU Enabled) To launch an action on detecting it

I used the udev system by creating a rule under /etc/udev/rules.d/10-local.rules

SUBSYSTEMS=="scsi", ATTRS{model}=="MK3006GAL       ", SYMLINK+="DAP", MODE="0666"
SUBSYSTEMS=="scsi", ATTRS{model}=="MK3006GAL       ", ACTION=="add", RUN+="/usr/local/bin/music-sync %k"

The first line creates a symbolic link called DAP under /dev/ \ The second line runs a script I wrote to sync (and mount if required) the device

@ascenderx
ascenderx / Xubuntu-Install.sh
Created September 2, 2021 05:29
Xubuntu installation history & notes
# Flash the image onto a USB stick.
# - Replace `/path/to/xubuntu.iso` with the appropriate ISO image.
# - Replace `sdX` with the appropriate device node.
sudo dd if=/path/to/xubuntu.iso of=/dev/sdX conv=fdatasync status=progress bs=1M
# Boot into the USB stick and run the installer.
# You might need to boot into the PC's UEFI settings to do so.
# Make sure the install medium is botted in UEFI mode!
# On the new installation, run the following installers.
@rdenadai
rdenadai / installer.sh
Last active November 22, 2023 09:24
Super complex set of script and text files to build a full feature computer with a lots of python libs, java and other stuff like ffmpeg, opencv, llvm inside a vagrant script or linux install!!!
# The commands must be executed in the order bellow! Not doing this may break the installation!
# Install python-software-properties if you get a 'command not found'
# sudo apt-get install python-software-properties
# In case you need to install setuptools
# Keep in mind that doing this may destroy pip installation of setuptools
# Instead you can pip install setuptools ... :)
# wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
#!/bin/bash
# Description:
# Script to query mpd's status and download a cover of the currently playing
# song on song-change and execute a user-defined command to show the cover.
# (e.g. with notify-send, by default with a image viewer for testing)
# Feel free to make your customizations here.
MPD_SERVER="--port 6600 --host localhost" # For default case.
@jjrh
jjrh / remember_good_song
Created August 22, 2013 15:12
tool for mpd that formats the output of mpc in a way I can remember it. If I like a song in my playlist dump its name and file location into $file_path
#!/bin/sh
# tool for mpd that formats the output of mpc in a way I can remember it.
# If I like a song in my playlist dump its name and file location into $file_path
#
file_path="~/temp/good_songs"
echo "--------------------------------------------------------------------------------" >> $file_path # note this line is 80characters wide.
SONG_INFO=`mpc status -f "%artist% - %title% \n%file%" | head -1`
SONG_LOCATION=`mpc status -f "%artist% - %title% \n%file%" | head -2 | tail -n -1`