Author Topic: lxcursor > Bash to Python  (Read 844 times)

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
lxcursor > Bash to Python
« on: July 14, 2010, 09:12:19 AM »
How about this as a project? Convert lxcursor, written in bash, into a python script. Any of you python guys want to tackle it?

This is the script in bash:
Code: [Select]
#!/bin/bash
#
# lxcursor 0.2
#
# based on pcursor 0.1 by wow <rockingfreak@gmail.com>
#
# Purpose: Change the default X cursor theme
#
# by Neal <nealbrks0@gmail.com>
# pinoc: changed to work with zenity and new bash 4
#

# temp folder
if [ ! -d $HOME/.config/tmp ]; then mkdir -p $HOME/.config/tmp; fi
LIST="$HOME/.config/tmp/lst01"

# delete old theme list
if [ -f "$LIST" ]; then rm -f "$LIST";fi

# create icon-theme list
CURSORLIST=`ls -d /usr/share/icons/*/cursors`
for i in $CURSORLIST; do echo $i | cut -d/ -f5 >> "$LIST";done

# define GUI
cd /tmp
echo 'XX=$(zenity --title "Select a Cursor Theme" --text "Please select the new cursor theme or press Cancel to quit.\nNOTE: you must logout to apply the new cursor theme\!" --list --height 300 --radiolist --column "Select" --column "Cursor Theme" ' > tt1
cat $LIST |sed 's/^/FALSE /' >> tt1
echo ');' >> tt1 && cat tt1 |tr "\n" " " > tt2 && echo "#"'!/bin/bash' > tt0
cat tt2 >> tt0 && echo ' ' >> tt0 && echo 'echo $XX > tt3' >> tt0
chmod u+x tt0 && /tmp/tt0 && LXC_SELECT=`less tt3`

# check if a new theme was selected and if so, apply it
if [ "$LXC_SELECT" == "" ];then  # just quit
  zenity --title "lxcursor" --info --text="Cursor theme unchanged."
  exit 0
else  # apply the new cursor theme and logout
  if [ -d $HOME/.icons/default ]; then rm -rf $HOME/.icons/default; fi
  if [ ! -d $HOME/.icons ]; then mkdir -p $HOME/.icons; fi
  ln -fs /usr/share/icons/$LXC_SELECT $HOME/.icons/default
  lxde-logout
fi

exit 0

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12657
Re: lxcursor > Bash to Python
« Reply #1 on: July 14, 2010, 09:29:12 AM »
I wish we had some perl-gtk coders and we could add these pclinuxos in house utilities to the PCLinuxOS Control Center.


Thanks to everyone who donates. You keep the servers running.
Follow me on Twitter for the latest development info.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: lxcursor > Bash to Python
« Reply #2 on: July 14, 2010, 09:33:11 AM »
I wish we had some perl-gtk coders and we could add these pclinuxos in house utilities to the PCLinuxOS Control Center.

Wish I knew it. :( Guess I should make time to start learning. ::)