Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

James W Mann jwmann

🎯
Focusing
View GitHub Profile
@jwmann
jwmann / ToggleOutputDevice.scpt
Created Mar 3, 2016
This is an AppleScript to toggle between 2 Sound Output Devices. Set your own Devices to toggle on lines 32 and 33
View ToggleOutputDevice.scpt
# Tell our specifc panel options to wake up.
tell application "System Preferences"
reveal anchor "output" of pane id "com.apple.preference.sound"
end tell
# Save our Current Output Device as well as a List of Available Output Devices.
tell application "System Events"
tell process "System Preferences"
tell window "Sound"
tell tab group 1
@jwmann
jwmann / AddiTunesFromVLC.scpt
Created Mar 3, 2016
This is an AppleScript to allow the ability to select a song from a VLC playlist and Add the song to your iTunes Library.
View AddiTunesFromVLC.scpt
global songAdded
global selectedSong
# This variable is used as a boolean to see if a file has been added to iTunes or not
set songAdded to false
# This variable is used to store the alias location of the song to be deleted / added
set selectedSong to false
getSong()
addSong(selectedSong)
@jwmann
jwmann / idleSleepDisplay.sh
Last active Mar 5, 2016
Sleep the Display if the user has been Idle for 30 minutes or more. Required: OS X 10.9+
View idleSleepDisplay.sh
#!/bin/sh
###########################################
##
## Name: idleSleepDisplay.sh
##
## Description: Sleep Display if Idle
## Author: James W Mann <me@jameswmann.com>
##
## Notes: Minimum Idle time is set for 30 minutes ( 1800 seconds ) by default.
@jwmann
jwmann / AddiTunesTrashFromVLC.scpt
Last active Mar 7, 2016
Select a song from VLC and run this Applescript to Add a song to iTunes, Trash it from its original location, and then removing it from the VLC Playlist. It has only been tested for a single song selection but can accomodate playlists of any size.
View AddiTunesTrashFromVLC.scpt
global songAdded
global songDeleted
global selectedSong
global safetyCheck
# This variable is used as a boolean to see if a file has been added to iTunes or not
set songAdded to false
# This variable is used as a boolean to see if a file has been deleted or not
set songDeleted to false
# This variable is used to store the alias location of the song to be deleted / added
@jwmann
jwmann / .profile
Last active Sep 18, 2016
Bash Functions for quickly setting the appropriate user for the git repo
View .profile
# GIT USER PROFILE SETTING / SWITCHING
# This will strip the current static User from the current repo and Include an external User profile.
# This function relies on: Git, A Git Repo, a config file located in ~/config/git/profilename.user.config
# Format must be profilename.user.config
# Usage: gituser home => ~/config/git/home.user.config
# Usage: gituser "Work GitHub" => ~/config/git/Work Github.user.config
gituser() {
# Sanity check
if [ -z "$(which git)" ]
then
@jwmann
jwmann / TrashSongFromVLC.scpt
Last active Jan 20, 2018
This is an AppleScript to allow the ability to select a song from a VLC playlist and Trash the song from your Disk and Remove it from the Playlist. It has only been tested for a single song selection but can accomodate playlists of any size.
View TrashSongFromVLC.scpt
global songDeleted
global selectedSong
global safetyCheck
# This variable is used as a boolean to see if a file has been deleted or not
set songDeleted to false
# This variable is used to store the alias location of the song to be deleted / added
set selectedSong to false
# This variable is used to track whether we've attempted a safe workaround to deleting a current song
set safetyCheck to false
@jwmann
jwmann / toggleAudioOutput.sh
Last active Sep 18, 2020
Toggle between two audio devices on macOS as a shell script. Set the devices on line 11 and 12. Requires Homebrew to be installed in the usual directory.
View toggleAudioOutput.sh
#! /bin/bash
# Author: James W Mann (jwmann)
# Dependencies: homebrew, SwitchAudioSource (https://github.com/deweller/switchaudio-osx)
# Notes: If SwitchAudioSource, the script will install it automatically
# See all audio devices: $> SwitchAudioSource -a
# Manually switch with: $> SwitchAudioSource -s device_name
toggle_audio() {
brew=/usr/local/bin/brew
if [ -f $brew ]; then
@jwmann
jwmann / brew-init.sh
Last active May 20, 2021
Initialize & Install Homebrew Tools and Apps
View brew-init.sh
#!/usr/bin/env sh
#
# Initialize & Install Default Homebrew / Casks
# To execute: save and `chmod +x ./brew-init.sh` then `./brew-init.sh`
#
# MacVim Requires the entirety of XCode to install, so install XCode before.
# Then Run `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer` to use those command-line tools.
# Modern Homebrew should be installing XCode commandline tools on its own if it's missing
# If it doesn't, `xcode-select --install` should install it.
#