Disable/Enable Wake My Macbook When Open Clamshell.scpt
--stale
property pass : false --na wstepie "reset" hasla
property login : "USER" --krotka nazwa uzytkownika, nalezy wstawic w "" swoja --koniec stale
on run --wykonuje polecenia w tym bloku po starcie, nie trzeba, ale mozna uzyc
--znak ¬ (Alt-Return w Script Editor) kontynuuje zapis polecenia w nowym wierszu, pomaga skracac wiersze
display dialog "Co ma robic Mac gdy spi, a Ty podnosisz klape?" buttons {"Cancel", "Spac dalej", "Budzic sie"} ¬
default button "Budzic sie" cancel button "Cancel" --dialog wyboru
set theAnswer to button returned of the result --ustawia zmienna na wybrany przycisk
display dialog "Podaj haslo:" default answer "" with hidden answer --okno dialogowe prosi o haslo administratora
set pass to text returned of result --ustawia haslo na podane
my lidMyMac(theAnswer) --wykonuje wybrane zadanie okreslone w zmiennej 'theAnswer'
end run
on lidMyMac(theAnswer)
if theAnswer is "Budzic sie" then --jesli wybrany ten przycisk
try
do shell script "pmset lidwake 0 && pmset lidwake 1" user name login password pass ¬
with administrator privileges --wykonuje skrypt powloki jako administrator
display alert "Mac bedzie sie budzil gdy podniesiesz klape." message "Gotowy do pracy zaraz po otwarciu oczu." --potwierdzenie
on error theError --jesli nieudane
set pass to false --"reset" hasla
display dialog "Nie udalo sie, sprobuj ponownie." & return & ¬
"Podaj haslo:" default answer "" with hidden answer --ponownie prosi o haslo
set pass to text returned of result --ustawia haslo na podane (po czym wraca do poczatku petli)
end try
--dalej podobnie dla alternatywnego przycisku, ale skrypt powloki wykonuje odwrotne polecenie
else if theAnswer is "Spac dalej" then
try
do shell script "pmset lidwake 1 && pmset lidwake 0" user name login password pass ¬
with administrator privileges
display alert "Teraz gdy podniesiesz klape," & return & ¬
"nie obudzisz Maka" message "Mozesz spokojnie wyczyscic ekran. :)"
on error theError
set pass to false
display dialog "Nie udalo sie, sprobuj ponownie." & return & ¬
"Podaj haslo:" default answer "" with hidden answer
set pass to text returned of result
end try
end if
end lidMyMac