Last active
May 26, 2018 00:57
-
-
Save Superdanby/fd864ba673975ca550f013bf3e9c9665 to your computer and use it in GitHub Desktop.
.bashrc-general, revive-bluetooth: bluetootth fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bashrc | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
PROMPT_COMMAND=ExitStatus | |
# Uncomment the following line if you don't like systemctl's auto-paging feature: | |
# export SYSTEMD_PAGER= | |
# User specific aliases and functions | |
alias lgot='gnome-session-quit' | |
alias vscode='code' | |
alias g+='g++ -Wall -Wextra -std=c++17 -O2' | |
alias gc='gcc -Wall -Wextra -std=gnu11' | |
alias cowsay='cowsay -f dragon-and-cow $1' | |
alias sshfs='sshfs -o reconnect,ServerAliveInterval=5,ServerAliveCountMax=3' | |
#The command 'command' is very important. It prevents functions to recursively call itself forever. | |
Green="\033[0;92m" | |
Red="\033[0;31m" | |
Frog="\xF0\x9F\x90\xB8" | |
Cross="\xE2\x9D\x8E" | |
White="\033[0m" | |
Cyan="\033[0;96m" | |
Bold=`tput bold` | |
NonBold=`tput sgr0` | |
Start=0 | |
OriginPS1=$PS1 | |
ExitStatus () { | |
Exit=$? | |
if [[ $Start != 0 ]]; then | |
printf "\n" | |
fi | |
Date=`date +%Y/%m/%d` | |
if [[ $Exit == 0 ]]; then | |
PS1="\[$Green\]\$(printf '$Frog')$Exit$OriginPS1\[$White\]$Date \t\n\[$Cyan\]\[$Bold\]~>\[$NonBold\]\[$White\] " | |
else | |
PS1="\[$Red\]\$(printf '$Cross')$Exit$OriginPS1\[$White\]$Date \t\n\[$Cyan\]\[$Bold\]~>\[$NonBold\]\[$White\] " | |
fi | |
Start=1 | |
} | |
cd () { | |
if [[ $# != 0 ]]; then | |
command cd "$@"; | |
fi | |
} | |
rm () { | |
Flag=0; | |
for i in "$@" | |
do | |
if [[ $i == '-f' || $i == '-rf' || $i == '-fr' ]]; then | |
Flag=1 | |
break | |
fi | |
done | |
if [[ $Flag == 1 ]]; then | |
printf "Removing in 3 seconds..." | |
Final=$(delay) | |
if [[ $Final == true ]]; then | |
command rm "$@" | |
fi | |
else | |
command rm -i "$@" | |
fi | |
} | |
delay () { | |
command sleep 3 | |
if [[ $? == 0 ]]; then | |
echo true | |
else | |
echo false | |
fi | |
} | |
after () { | |
min=$1 | |
shift | |
echo "notify-send '$@'" | at now + $min minute | |
} | |
bind "TAB:menu-complete" | |
bind '"\e[Z":menu-complete-backward' | |
bind "set show-all-if-ambiguous on" | |
bind "set menu-complete-display-prefix on" | |
bind "\C-h:backward-kill-word" | |
bind '"\e[3;5~":shell-kill-word' | |
LS_COLORS=$LS_COLORS:'di=0;33' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Revive Bluetooth | |
[Service] | |
Type=simple | |
ExecStart=/usr/bin/revive-bluetooth.sh | |
Restart=on-failure | |
RestartSec=5 | |
[Install] | |
WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sudo modprobe -r btusb | |
sleep 3 | |
sudo modprobe btusb | |
sleep 2 | |
if [[ `hcitool dev | grep hci0` == '' ]];then | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment