Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Share your Scripts
New Posts  All Forums:Forum Nav:

Share your Scripts - Page 4

post #31 of 305
Quote:
Originally Posted by tom.slick View Post

example prompt for sudo (Click to show)
Code:
#!/bin/bash

# check for root
# $UID 0 is root
if [ $UID != 0 ] ; then
  clear
  echo "This script requires root premissions to continue"
  read -p "(Y to continue anything else to exit)" y
  case $y in
      [Yy]* )
         # command to prompt for password
          sudo $0;
          Exit_Command=$?;;
      * )
          # exit script 
          Exit_Command=1
  esac
  exit $Exit_Command
fi

# script now has root privliges
echo "Root granted"
Yes, you could also ask them if they want to reboot now and do it for them, use the reboot or shutdown commands
Code:
shutdown -r now
or 
reboot

OK...so do I need to put the sed commands into that loop after the sudo part? I think I followed it up until the case and esac part. Never seen those before so I'm going to have to go digging around for some explanations that will make sense for me. I'm actually just thinking having it sudo before the sed as that seems simpler. But I might use what you showed me if I can figure out how to get it to work. Thanks.
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
post #32 of 305
once you use the sudo the script will have root
use it like this Warning: Spoiler! (Click to show)
Code:
#!/bin/sh
#Script made on April 12, 2014 by Rookie1337
#Goal is to make the "best" changes to pulseaudio

#This is the variable declaration section.
#Use a #before each set if you wish to disable a set.
#You need only change the numerical values of the priority;
#...and limits non-default settings to match your liking.

if [ $UID != 0 ] ; then
  clear
  echo "This script requires root premissions to continue"
  read -p "(Y to continue anything else to exit)" y
  case $y in
      [Yy]* )
         # command to prompt for password
          sudo $0;
          Exit_Command=$?;;
      * )
          # exit script 
          Exit_Command=1
  esac
  exit $Exit_Command
fi

realtime_on="  realtime-scheduling = yes"
realtime_off="; realtime-scheduling = no"
realtime_priority_on="  realtime-priority = 40"
realtime_priority_off="; realtime-priority = 9"
best_resampling="  resample-method = src-sinc-best-quality"
default_resampling="; resample-method = speex-float-10"
default_eq="; flat-volumes = yes"
best_eq="  flat-volumes = no"
default_rtlimit="; rlimit-rtprio = 9"
best_rtlimit="  rlimit-rtprio = 40"

#This section enables the changes you want from default
sed "s/$realtime_off/$realtime_on/g ;
s/$realtime_priority_off/$realtime_priority_on/g ;
s/$default_resampling/$best_resampling/g ;
s/$default_eq/$best_eq/g ;
s/$default_rtlimit/$best_rtlimit/g" daemon.conf 


#This section returns everything to default
#Delete the # before each of the following lines;
#...and run the script again to undo all changes.
#sed "s/$realtime_on/$realtime_off/g ;
#s/$realtime_priority_on/$realtime_priority_off/g ;
#s/$best_resampling/$default_resampling/g ;
#s/$best_eq/$default_eq/g ;
#s/$best_rtlimit/$default_rtlimit/g" daemon.conf

echo "The computer needs to be rebooted for the changes to take affect"
read -p "R to Reboot now or anything else to exit" r
case $r in
    [Rr]* )
        echo "rebooting now"
        shutdown -r now
        Exit_Command=$?;;
    * )
        echo "Remember that for the settings to take affect";
        echo "the computer will need to be rebooted"
        Exit_Command=1
  esac
  exit $Exit_Command
fi

Edited by tom.slick - 4/12/14 at 9:55pm
Core I7
(13 items)
 
  
CPUMotherboardGraphicsRAM
I7 920 rev. D0 @ 4.26Ghz EVGA X58 SLI EVGA GTX 285 OCZ XMP 3x2Gb (pc3 12800) 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 640Gb x 2 LG GH22LS30 openSuse 12.1 x64 HP F2105 
PowerCase
CORSAIR 850TX Cooler Master ATCS 840 
  hide details  
Reply
Core I7
(13 items)
 
  
CPUMotherboardGraphicsRAM
I7 920 rev. D0 @ 4.26Ghz EVGA X58 SLI EVGA GTX 285 OCZ XMP 3x2Gb (pc3 12800) 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 640Gb x 2 LG GH22LS30 openSuse 12.1 x64 HP F2105 
PowerCase
CORSAIR 850TX Cooler Master ATCS 840 
  hide details  
Reply
post #33 of 305
Here's a basic one-liner I threw together a while back for generic laptop diagnostics (mostly for backlight) it could be easily modified to provide a more well formatted presentation, and be bbcode enabled and give you more information, but it's nice because its something a user can copy & paste to get exactly the info you want:
Code:
( echo $' lspci: \r\n' ; lspci ; echo $'\r\n lsusb: \r\n' ; lsusb ; echo $'\r\n /proc/acpi: \r\n' ; ls /proc/acpi ; echo $'\r\n /sys/class/backlight: \r\n' ; ls /sys/class/backlight ; echo $'\r\n Installed Packages: \r\n' ; pacman -Qs nvidia catalyst radeon fglrx intel dri laptop ) > ~/diagnostics.txt
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
post #34 of 305
Quote:
Originally Posted by CSCoder4ever View Post

good point, doing a quick google search I could use git on my local network.
ah well, it was a good challenge anyways!

I happen to be in the process of trying to learn Git myself (for tracking config files). Github has a really great walk through tutorial on their site: one command at a time, type in the command and see the output. It's really nice the way it walks through all the basic steps of creating a repo and branching. It covers connecting to and syncing with Github in the latter parts but this may not necessarily translate to doing so over the LAN (it's actually quite generic, no requirement to use github). This linux.com article covers that in the context of tracking config files but it would cover what you're looking for (and discusses SSH keys which may come up).

Here are some other links I found in my research. Actually I have others but I didn't want to get carried away. That happens with me sometimes. I can post them if there's interest though smile.gif



Oh and to stay on subject I was using something like this to automate webmin installs. Still have to chmod +x to make it of course though. I really this could all be done on one line but I'm kind of in a debug mode with my scripts. I like to see it all scroll by one at a time and this makes it more readable to me. Just weird that way I guess. Also, have to use it with sudo.
Code:
# script name: install-webmin.sh - created march 2014
#!/bin/sh
wget http://www.webmin.com/jcameron-key.asc && apt-key add jcameron-key.asc 

apt-get update

apt-get -y upgrade

apt-get -y install webmin


Edited by subassy - 4/13/14 at 5:50pm
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #35 of 305
Grr...I'm stumped again...I can't figure out why my append sed usage doesn't work. I read the man and looked at guides and I don't get any error as to why it won't work. The point in question is at the end before the echo section. Anyone got an idea as I've been scratching my head about it all day. Also, how much would it take for someone to write a better, more interactive, and idiot proof script? I think mine just isn't going to be good enough. redface.gif

So I'm going to have to take a break on working on it for a while because of finals. If anyone wants to help I'd be grateful as I think a script is far better than my guide.
Pulseaudio config fixing script unfinished (Click to show)
Code:
#!/bin/sh
#Script made on April 12, 2014 by Rookie1337
#Goal is to make the "best" changes to pulseaudio

#This section of code was provided by oc.net user tom.slick
# check for root
# $UID 0 is root
#if [ $UID != 0 ] ; then
#  clear
#  echo "This script requires root premissions to continue"
#  read -p "(Y to continue anything else to exit)" y
#  case $y in
#      [Yy]* )
#         # command to prompt for password
#          sudo $0;
#          Exit_Command=$?;;
#      * )
#          # exit script 
#          Exit_Command=1
#  esac
#  exit $Exit_Command
#fi
# script now has root privliges
#echo "Root granted"


#This is the variable declaration section.
#Use a #before each set if you wish to disable a set.
#You need only change the numerical values of the priority;
#...and limits non-default settings to match your liking.

realtime_on="  realtime-scheduling = yes"
realtime_off="; realtime-scheduling = no"
realtime_priority_on="  realtime-priority = 40"
realtime_priority_off="; realtime-priority = 9"
best_resampling="  resample-method = src-sinc-best-quality"
default_resampling="; resample-method = speex-float-10"
default_eq="; flat-volumes = yes"
best_eq="  flat-volumes = no"
default_rtlimit="; rlimit-rtprio = 9"
best_rtlimit="  rlimit-rtprio = 40"

#Variables for the limits file
#Make sure the rtprio here matches the rlimit-rtprio you set in the previous...
#...variable declaration section.
USER="rez"
new_rtprio="$USER           -       rtprio          40"

#The following makes a backup of the default pulseaudio config
#Disable the following line with a # before the sudo...
#...after you run this script once.

#sudo cp /etc/pulse/daemon.conf /etc/pulse/daemon.conf.old

#The following restores the default config.
#If you have problems delete the # before the sudo...
#...and run the script again and it will restore your original.

#sudo cp /etc/pulse/daemon.conf.old /etc/pulse/daemon.conf


#The following section enables the changes to improve over...
#...the default daemon.conf file.

sudo sed "s/$realtime_off/$realtime_on/g ;
s/$realtime_priority_off/$realtime_priority_on/g ;
s/$default_resampling/$best_resampling/g ;
s/$default_eq/$best_eq/g ;
s/$default_rtlimit/$best_rtlimit/g" daemon.conf 

#The following section returns everything to default if your default...
#...config file is missing or deleted.
#Delete the # before each of the following lines...
#...and run the script again to undo all changes.

#sed "s/$realtime_on/$realtime_off/g ;
#s/$realtime_priority_on/$realtime_priority_off/g ;
#s/$best_resampling/$default_resampling/g ;
#s/$best_eq/$default_eq/g ;
#s/$best_rtlimit/$default_rtlimit/g" daemon.conf 

#This section provides the changes necessary to the limits...
#...file to enable the realtime settings to be enabled.
sudo sed "56 a\ 
$new_rtprio
" limits.conf


echo "Please reboot for changes to take effect"

PS: @tom.slick....I feel stupid as even with the demonstration you provided I can't get your sudo prompt to work inside my script. It keeps saying "Sedpractice.sh not a valid command".
Edited by Rookie1337 - 4/13/14 at 5:59pm
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
post #36 of 305
Here's a script I wrote sometime around the beginning of last year - it's currently the only method for remapping the keys on the side of a Naga Epic:
Code:
remote_id=$(
  xinput list |
  sed -n 's/.*Naga.*id=\([0-9]*\).*keyboard.*/\1/p'
)
[ "$remote_id" ] || exit

mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF
xkb_symbols "remote" {
    key <AE01>   { [F1, F1] };
    key <AE02>   { [F2, F2] };
    key <AE03>   { [F3, F3] };
    key <AE04>   { [F4, F4] };
    key <AE05>   { [F5, F5] };
    key <AE06>   { [F6, F6] };
    key <AE07>   { [F7, F7] };
    key <AE08>   { [F8, F8] };
    key <AE09>   { [F9, F9] };
    key <AE10>   { [F10, F10] };
    key <AE11>   { [F11, F11] };
    key <AE12>   { [F12, F12] };
};
EOF

setxkbmap -device $remote_id -print | sed 's/\(xkb_symbols.*\)"/\1+custom(remote)"/' | xkbcomp -I/tmp/xkb -i $remote_id -synch - $DISPLAY 2>/dev/null
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
post #37 of 305
Quote:
Originally Posted by Rookie1337 View Post

Grr...I'm stumped again...I can't figure out why my append sed usage doesn't work. I read the man and looked at guides and I don't get any error as to why it won't work. The point in question is at the end before the echo section. Anyone got an idea as I've been scratching my head about it all day. Also, how much would it take for someone to write a better, more interactive, and idiot proof script? I think mine just isn't going to be good enough. redface.gif

So I'm going to have to take a break on working on it for a while because of finals. If anyone wants to help I'd be grateful as I think a script is far better than my guide.
Pulseaudio config fixing script unfinished (Click to show)
Code:
#!/bin/sh
#Script made on April 12, 2014 by Rookie1337
#Goal is to make the "best" changes to pulseaudio

#This section of code was provided by oc.net user tom.slick
# check for root
# $UID 0 is root
#if [ $UID != 0 ] ; then
#  clear
#  echo "This script requires root premissions to continue"
#  read -p "(Y to continue anything else to exit)" y
#  case $y in
#      [Yy]* )
#         # command to prompt for password
#          sudo $0;
#          Exit_Command=$?;;
#      * )
#          # exit script 
#          Exit_Command=1
#  esac
#  exit $Exit_Command
#fi
# script now has root privliges
#echo "Root granted"


#This is the variable declaration section.
#Use a #before each set if you wish to disable a set.
#You need only change the numerical values of the priority;
#...and limits non-default settings to match your liking.

realtime_on="  realtime-scheduling = yes"
realtime_off="; realtime-scheduling = no"
realtime_priority_on="  realtime-priority = 40"
realtime_priority_off="; realtime-priority = 9"
best_resampling="  resample-method = src-sinc-best-quality"
default_resampling="; resample-method = speex-float-10"
default_eq="; flat-volumes = yes"
best_eq="  flat-volumes = no"
default_rtlimit="; rlimit-rtprio = 9"
best_rtlimit="  rlimit-rtprio = 40"

#Variables for the limits file
#Make sure the rtprio here matches the rlimit-rtprio you set in the previous...
#...variable declaration section.
USER="rez"
new_rtprio="$USER           -       rtprio          40"

#The following makes a backup of the default pulseaudio config
#Disable the following line with a # before the sudo...
#...after you run this script once.

#sudo cp /etc/pulse/daemon.conf /etc/pulse/daemon.conf.old

#The following restores the default config.
#If you have problems delete the # before the sudo...
#...and run the script again and it will restore your original.

#sudo cp /etc/pulse/daemon.conf.old /etc/pulse/daemon.conf


#The following section enables the changes to improve over...
#...the default daemon.conf file.

sudo sed "s/$realtime_off/$realtime_on/g ;
s/$realtime_priority_off/$realtime_priority_on/g ;
s/$default_resampling/$best_resampling/g ;
s/$default_eq/$best_eq/g ;
s/$default_rtlimit/$best_rtlimit/g" daemon.conf 

#The following section returns everything to default if your default...
#...config file is missing or deleted.
#Delete the # before each of the following lines...
#...and run the script again to undo all changes.

#sed "s/$realtime_on/$realtime_off/g ;
#s/$realtime_priority_on/$realtime_priority_off/g ;
#s/$best_resampling/$default_resampling/g ;
#s/$best_eq/$default_eq/g ;
#s/$best_rtlimit/$default_rtlimit/g" daemon.conf 

#This section provides the changes necessary to the limits...
#...file to enable the realtime settings to be enabled.
sudo sed "56 a\ 
$new_rtprio
" limits.conf


echo "Please reboot for changes to take effect"

PS: @tom.slick....I feel stupid as even with the demonstration you provided I can't get your sudo prompt to work inside my script. It keeps saying "Sedpractice.sh not a valid command".
Code:
sudo $0
sed -i "s/$realtime_off/$realtime_on/g ;
s/$realtime_priority_off/$realtime_priority_on/g ;
s/$default_resampling/$best_resampling/g ;
s/$default_eq/$best_eq/g ;
s/$default_rtlimit/$best_rtlimit/g" /etc/pulse/daemon.conf 

You only need to use "sudo" once in the script, then the script will have sudo permissions for the rest of the commands in the script

use sed with the -i option
sed -i "s/$old/$new/g" /path/to/filename

if you want it to make a backup of the file first then use
sed -i.bak "s/$old/$new/g" /path/to/filename
Code:
-i[SUFFIX]
--in-place[=SUFFIX]
This option specifies that files are to be edited in-place. GNU sed does this by creating a temporary file and sending output to this file rather than to the standard output.1.
This option implies -s.

When the end of the file is reached, the temporary file is renamed to the output file's original name. The extension, if supplied, is used to modify the name of the old file before renaming the temporary file, thereby making a backup copy2).

This rule is followed: if the extension doesn't contain a *, then it is appended to the end of the current filename as a suffix; if the extension does contain one or more * characters, then each asterisk is replaced with the current filename. This allows you to add a prefix to the backup file, instead of (or in addition to) a suffix, or even to place backup copies of the original files into another directory (provided the directory already exists).

If no extension is supplied, the original file is overwritten without making a backup.
Core I7
(13 items)
 
  
CPUMotherboardGraphicsRAM
I7 920 rev. D0 @ 4.26Ghz EVGA X58 SLI EVGA GTX 285 OCZ XMP 3x2Gb (pc3 12800) 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 640Gb x 2 LG GH22LS30 openSuse 12.1 x64 HP F2105 
PowerCase
CORSAIR 850TX Cooler Master ATCS 840 
  hide details  
Reply
Core I7
(13 items)
 
  
CPUMotherboardGraphicsRAM
I7 920 rev. D0 @ 4.26Ghz EVGA X58 SLI EVGA GTX 285 OCZ XMP 3x2Gb (pc3 12800) 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 640Gb x 2 LG GH22LS30 openSuse 12.1 x64 HP F2105 
PowerCase
CORSAIR 850TX Cooler Master ATCS 840 
  hide details  
Reply
post #38 of 305
Here's a couple of scripts I wrote a long time ago. I need to go through my backups and see what scripts are still of use to me and get them back on my main install....

XBMC doesn't have a borderless Windowed option, to fix this I set it to windowed mode and used wmctrl to remove the decorations: Warning: Spoiler! (Click to show)
Code:
#! /bin/bash
# Launch XBMC in windowed mode, then use wmctrl to remove the titlebar
 
# Select display 1
DISPLAY=:0.1
 
# Start XBMC without blocking this script
xbmc &
 
# Wait for the XBMC window to appear
status=0
while [ $status -eq 0 ]
do
    sleep 1
 status=`wmctrl -x -l | grep "XBMC Media Center" | wc -l | awk '{print $1}'`
done     

# Force XBMC window to fullscreen
wmctrl -x -r XBMC Media Center.XBMC Media Center -b toggle,fullscreen


For those of us with a very lightweight install, here's a script that changes wallpapers using feh every 15 minutes: Warning: Spoiler! (Click to show)
Code:
#!/bin/sh

while true; do
        find ~/wallpapers -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
                shuf -n1 -z | xargs -0 feh --bg-center
        sleep 15m
done
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
post #39 of 305
Quote:
Originally Posted by Xaero252 View Post

For those of us with a very lightweight install, here's a script that changes wallpapers using feh every 15 minutes: Warning: Spoiler! (Click to show)
Code:
#!/bin/sh

while true; do
        find ~/wallpapers -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
                shuf -n1 -z | xargs -0 feh --bg-center
        sleep 15m
done

I actually hadn't thought about using feh like that. I might write my own to do something similar with all of my tile backgrounds...
post #40 of 305
Quote:
Originally Posted by Shrak View Post

I actually hadn't thought about using feh like that. I might write my own to do something similar with all of my tile backgrounds...

And this is why I love the *nix community. Even those of us with generally superior knowledge "learn" something new every day. I can see yours now:
Slightly brighter tiles at night, really dark tiles during the day, cycling periodically.... So hawt.
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Share your Scripts