OLD | NEW |
1 #! /bin/sh | 1 #! /bin/sh |
2 # | 2 # |
3 # Script to start or stop laptop_mode, and to control various settings of the | 3 # Script to start or stop laptop_mode, and to control various settings of the |
4 # kernel, hardware etc. that influence power consumption. | 4 # kernel, hardware etc. that influence power consumption. |
5 # | 5 # |
6 # This script is a part of Laptop Mode Tools. If you are running a supported | 6 # This script is a part of Laptop Mode Tools. If you are running a supported |
7 # power management daemon, this script will be automatically called on power | 7 # power management daemon, this script will be automatically called on power |
8 # state change. | 8 # state change. |
9 # | 9 # |
10 # Configure laptop mode tools in /etc/laptop-mode/laptop-mode.conf, and in | 10 # Configure laptop mode tools in /etc/laptop-mode/laptop-mode.conf, and in |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 FORCE=0 # Force reapplying the current state? | 520 FORCE=0 # Force reapplying the current state? |
521 while [ "$1" != "" ] ; do | 521 while [ "$1" != "" ] ; do |
522 case "$1" in | 522 case "$1" in |
523 init) INIT=1 ;; | 523 init) INIT=1 ;; |
524 force) FORCE=1 ;; | 524 force) FORCE=1 ;; |
525 # Old options. We always do "auto" for any option now, but | 525 # Old options. We always do "auto" for any option now, but |
526 # we still have to accept the options. | 526 # we still have to accept the options. |
527 start) ;; | 527 start) ;; |
528 stop) ;; | 528 stop) ;; |
529 auto) ;; | 529 auto) ;; |
| 530 modules=*) |
| 531 MODULES=$1 |
| 532 MODULES=${MODULES#"modules="} |
| 533 ;; |
| 534 devices=*) |
| 535 DEVICES=$1 |
| 536 DEVICES=${DEVICES#"devices="} |
| 537 ;; |
530 *) log "ERR" "Unrecognized option $1." | 538 *) log "ERR" "Unrecognized option $1." |
531 exit 1 ;; | 539 exit 1 ;; |
532 esac | 540 esac |
533 shift | 541 shift |
534 done | 542 done |
535 | 543 |
536 mkdir -p /var/run/laptop-mode-tools | 544 mkdir -p /var/run/laptop-mode-tools |
537 | 545 |
538 # Used to display laptop mode state later on. This is the enabled/disabled | 546 # Used to display laptop mode state later on. This is the enabled/disabled |
539 # state for laptop mode processing, it tells us nothing about whether laptop | 547 # state for laptop mode processing, it tells us nothing about whether laptop |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1012 |
1005 | 1013 |
1006 | 1014 |
1007 | 1015 |
1008 | 1016 |
1009 # Finally, call laptop-mode-tools modules. The modules can use the settings | 1017 # Finally, call laptop-mode-tools modules. The modules can use the settings |
1010 # from the config files, but they may NOT assume the settings actually exist, | 1018 # from the config files, but they may NOT assume the settings actually exist, |
1011 # as no defaults have been given for them. | 1019 # as no defaults have been given for them. |
1012 | 1020 |
1013 # Note that the /usr/local/lib path is deprecated. | 1021 # Note that the /usr/local/lib path is deprecated. |
1014 export FORCE STATE ON_AC ACTIVATE ACTIVATE_WITH_POSSIBLE_DATA_LOSS KLEVEL KMINOR
WAS_ACTIVE LM_VERBOSE | 1022 export FORCE STATE ON_AC ACTIVATE ACTIVATE_WITH_POSSIBLE_DATA_LOSS KLEVEL KMINOR
WAS_ACTIVE LM_VERBOSE DEVICES |
1015 for SCRIPT in /usr/share/laptop-mode-tools/modules/* /usr/local/lib/laptop-mode-
tools/modules/* /usr/local/share/laptop-mode-tools/modules/* /etc/laptop-mode/mo
dules/*; do | 1023 for SCRIPT in /usr/share/laptop-mode-tools/modules/* /usr/local/lib/laptop-mode-
tools/modules/* /usr/local/share/laptop-mode-tools/modules/* /etc/laptop-mode/mo
dules/* ; do |
1016 » if [ -x "$SCRIPT" ] ; then | 1024 » if [ -z "$MODULES" ] ; then |
| 1025 » » # If a module list has not been provided, execute all modules |
| 1026 » » EXECUTE_SCRIPT=1 |
| 1027 » else |
| 1028 » » # If a module list has been provided, execute only the listed |
| 1029 » » # modules. |
| 1030 » » EXECUTE_SCRIPT=0 |
| 1031 » » for MODULE in $MODULES; do |
| 1032 » » » # Attempt to remove the module name from the end of the |
| 1033 » » » # full script path. If the module name matches the |
| 1034 » » » # script, the name will be removed from the end of the |
| 1035 » » » # full file path, leaving the path to the script. If |
| 1036 » » » # there was not a match made, the module name would not |
| 1037 » » » # be removed from the path, and $PATH_TO_SCRIPT would |
| 1038 » » » # be the same as $SCRIPT. |
| 1039 » » » PATH_TO_SCRIPT=${SCRIPT%%$MODULE} |
| 1040 » » » # Execute the script if a match was found (module name |
| 1041 » » » # was removed from the script path, making it shorter. |
| 1042 » » » if [ $PATH_TO_SCRIPT != $SCRIPT ] ; then |
| 1043 » » » » EXECUTE_SCRIPT=1 |
| 1044 » » » fi |
| 1045 » » done |
| 1046 » fi |
| 1047 |
| 1048 » if [ -x "$SCRIPT" -a $EXECUTE_SCRIPT -eq 1 ] ; then |
1017 log "VERBOSE" "Invoking module $SCRIPT." | 1049 log "VERBOSE" "Invoking module $SCRIPT." |
1018 SCRIPT_DEBUG=$SCRIPT; # We do this because in start-stop-program
s module a $SCRIPT variable is used. That | 1050 » » SCRIPT_DEBUG=$SCRIPT; # We do this because in start-stop-program
s module a $SCRIPT variable is used. That |
1019 # changes the whole meaning when passed to
disableDebug () | 1051 » » » » # changes the whole meaning when passed to
disableDebug () |
1020 enableDebug $SCRIPT_DEBUG; | 1052 » » enableDebug $SCRIPT_DEBUG; |
1021 . $SCRIPT | 1053 » » . $SCRIPT |
1022 disableDebug $SCRIPT_DEBUG; | 1054 » » disableDebug $SCRIPT_DEBUG; |
1023 else | 1055 else |
1024 » » log "VERBOSE" "Module $SCRIPT is not executable." | 1056 » » log "VERBOSE" "Module $SCRIPT is not executable or is to be skip
ped." |
1025 fi | 1057 fi |
1026 done | 1058 done |
1027 | 1059 |
1028 | 1060 |
1029 exit 0 | 1061 exit 0 |
1030 | 1062 |
1031 # This fi closes the if for "readconfig". If I would have indented this one | 1063 # This fi closes the if for "readconfig". If I would have indented this one |
1032 # I would have indented the whole file. :) | 1064 # I would have indented the whole file. :) |
1033 fi | 1065 fi |
OLD | NEW |