Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
<code>sleep</code> pauses the execution of your script for a number of
seconds. It basically takes a number as an argument, then does nothing
for that number of seconds, and then returns. It can be useful if you
want to make your script do something in a loop, but want to throttle
the speed a little.
</p>
<pre>
<code>
# prints "Get back to work" once per second. {"\n"}# Note that 'true'
is a command that always returns 0.{"\n"}while true{"\n"}do{"\n"}
{" "}echo 'Get back to work!'{"\n"}
{" "}sleep 1{"\n"}done
</code>
</pre>
<p>
<strong>mplayer or mpv</strong>
</p>
<p>
<code>mplayer</code> and <code>mpv</code> are media players that can be
used from the console. <code>mpv</code> is based on <code>mplayer</code>{" "}
and a lot more modern, but they can do essentially the same.
</p>
<pre>
<code>
# play file "music.mp3"{"\n"}mplayer 'music.mp3'{"\n"}mpv 'music.mp3'
{"\n"}
{"\n"}# play file "alarm.mp3" in an infinite loop{"\n"}mplayer -loop 0
'alarm.mp3'{"\n"}mplayer --loop=inf 'alarm.mp3'{"\n"}
{"\n"}# play a youtube video{"\n"}# this only works with mpv and
requires youtube-dl to be installed{"\n"}mpv
'https://www.youtube.com/watch?v=lAIGb1lfpBw'
</code>
</pre>
<p>
<strong>xdotool</strong>
</p>
<p>
<code>xdotool</code> can simulate keypresses. With this command, you can
write macros that perform actions for you. It allows you to write
scripts that interact with GUI programs.
</p>
<pre>
<code>
# press ctrl+s (in order to save a document){"\n"}xdotool key
'Control+s'
{"\n"}
{"\n"}# type "hello"{"\n"}xdotool type 'hello'
</code>
</pre>
{/* end pandoc */}
</>
);
}