Something funny happened to me today. I logged in to my desktop machine at my workplace when a warning message told me that “disk space is low”. A quick “
df -h” indicated that it’s true, my HDD is at 100%! How is it possible, I should occupy no more than 30%. After hunting for 10 minutes for the guilty file/directory, it turned out that the file
.xsession-errors in my HOME directory grew more than 200GB! WTF?
I removed this file and under the name
.xsession-errors I put a link on
/dev/null. However, after a reboot the symbolic link was gone and
.xsession-errors became a regular file again. Tricky :) So I added the following lines to the end of my
# .xsession-errors can grow huge... remove it if [ ! -h $HOME/.xsession-errors ] then /bin/rm $HOME/.xsession-errors ln -s /dev/null $HOME/.xsession-errors fi if [ ! -h $HOME/.xsession-errors.old ] then /bin/rm $HOME/.xsession-errors.old ln -s /dev/null $HOME/.xsession-errors.old fi
It verifies if
.xsession-errors is a symbolic link. If not, remove it and replace it with a symbolic link.
Is there a way to lock/unlock the screen from a script?
The answer is “yes”. Lock the screen:
Unlock the screen:
Demo (lock the screen, then unlock it in 5 seconds):
gnome-screensaver-command -l && sleep 5 && gnome-screensaver-command -d
Tip from here.
Alt key brings up the HUD. How to get rid of it?
Launch System Settings, then Keyboard -> Shortcuts -> Launchers. On Key to show the HUD, press
Backspace to disable it.
You want to rip a streamed radio.
- fetch StreamRipStar, which is a frontend for streamripper
- install streamripper (via apt-get)
- configure StreamRipStar, specify the audio stream’s URL and start ripping
If you want to rip Slay Radio (best Commodore 64 tunes!), use this address: http://relay3.slayradio.org:8000/.
Under Gnome/Unity, you want to increase the number of virtual workspaces.
Start CompizConfig Settings Manager (
ccsm), then General -> General Options -> Desktop Size tab. Here adjust the horizontal and vertical virtual size.
The title of this post is a reference to a novel of Harry Harrison.
On my Linux box, VLC gets stuck sometimes and only the good old “
kill -9” can shoot it out. Is there a single command to kill it?
alias killvlc='kill -9 `ps ux | grep vlc | grep -v grep | tr -s " " | cut -d" " -f2`'
I wanted to convert a PDF with Calibre but it failed. I tried with Online Convert(er) too and it succeeded…
Torcache is a free service for caching t. files online. I noticed by accident (got a timeout error…) that one big t. site stores its t. files here too.
For my everyday work I use Linux. I also have a Windows 7 in VirtualBox. Under Windows I’ve found a very nice movie catalogue called Movie Collector. It’s not free though; unfortunately I didn’t find any good open-source alternative for this task.
So, I had this software running in VirtualBox and I wanted to input a list of movies. I collected the list in a file. Movie Collector has a GUI interface where you can insert the title of a movie and it’s put in a queue (see the figure below). Then you can verify for each item if it found the correct movie.
The question is: how to insert the movie titles via the GUI interface in an automated fashion? I won’t type 100 titles by hand…
It’s a perfect job for Python. There is a great module called autopy that includes functions for controlling the keyboard and mouse. I already had it under Linux. Fortunately, you can launch an autopy script under Linux and it can interact with a Windows GUI that runs in VirtualBox.
The idea is simple: read the input file, where there is a movie title in each line. Put the movie title on the clipboard (we are lucky again, if you put something on the clipboard under Linux, it’s available under Windows too in VirtualBox). Click in the Title text field, select everything with
Del to delete the content, paste from the clipboard and click on the Add to Queue button. Then repeat: take the next movie title, etc.
The following script does exactly this:
#!/usr/bin/env python from autopy import key from time import sleep from jabbapylib.mouse import mouse from jabbapylib.clipboard.clipboard import text_to_clipboards TITLE = (68, 124) # input text field's position ADD = (575, 123) # button's position def delete(): mouse.click_to(TITLE) key.tap('a', key.MOD_CONTROL) # Ctrl+A key.tap(key.K_DELETE) # Del sleep(.1) def paste(): mouse.click_to(TITLE) key.tap('v', key.MOD_CONTROL) # Ctrl+V sleep(.1) def add(): mouse.click_to(ADD) sleep(.1) def main(): cnt = 0 with open('movies.txt') as f: for title in f: title = title.rstrip('\n') text_to_clipboards(title) delete() paste() add() cnt += 1 print cnt ############################################################################# if __name__ == "__main__": print 'Switch to VirtualBox...' sleep(3) main()
The imported modules are here:
To figure out the position of GUI elements (to know where to click to), you can use this little helper.