Author Topic: steamapps-linker (Looking for testers)  (Read 2680 times)

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
steamapps-linker (Looking for testers)
« on: November 04, 2011, 04:22:10 PM »
Looking for testers - Requires yad
I'm looking for testers, I do have 1 known issue. The script seems to pickup the disk, but the link will be unknown until you click on your Windows media to activate it.

If you would like to test this but don't know how to run this script please PM me.

Current state as of 1:09PM 11/06/2011 EST
Code: [Select]
#!/bin/sh
#This is a script to help users link the steamapps folder
#By glamdring


#variables
#=========
#WICON='/usr/share/icons/sc-maker.png' && TITLE="Shortcut Maker"
TITLE=$"Steamapps Linker"
YAD2="yad"
EMSG=$"No changes were made to your system."


#export
#======
export TEXTDOMAIN=shortcut-maker
export TEXTDOMAINDIR="/usr/share/locale"


#Creat a shortcut?
#================
MSG=$"No changes were made to your system."
MSG2=$"Do you want to link steamapps?"
$YAD2 --form --title="$TITLE" --text="$MSG2" --button="gtk-yes:0" --button="gtk-no:1" --sticky --fixed ret=$?
if [ "$?" = "1" ]; then
  $YAD2 --title="$TITLE" --form --notification --text="$MSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
  if  [ "$?" = "1" ]; then
  "/usr/bin/steamapps-linker"
  fi
  exit 0
fi

#Find User
#=========
CUID=`whoami`
AUID=`cat /etc/passwd | grep "/home" |cut -d: -f1`

#What user should we link?
#=========================
MSG=$"What account/user would you like to put the steamapps link on"
MSG2=$"Is this the account you want the steamapps link on? \n \n $CUID"
MFS="no"
$YAD2 --form --title="$TITLE" --text="$MSG2" --button="gtk-yes:0" --button="gtk-no:1" --sticky --fixed ret=$?
if [ "$?" = "1" ]; then
CUID=$($YAD2 --title=$"Select User for link" --width 400 --entry $AUID --button="gtk-ok:0" --button="None:1") ret=$?
if [ "$?" = "1" ]; then

#File selection
#==============
MSG=$"Please select your linux steamapps directory"
MSG2=$"For PlayOnLinux most likly \n /home/user/.PlayOnLinux/wineprefix/Steam/drive_c/Program Files/Steam/steamapps \n \n For Wine most likly \n /home/$CUID/.wine/drive_c/Program Files/Steam/steamapps"
MSG3=$"Contents of the directory you have chosen is:"
LSAPP=$($YAD2 --file --title="$TITLE" --text "$MSG2 \n " --width 800 --height 600 --button="gtk-ok:0" --button="gtk-cancel:1") ret=$?
if [ "$?" = "1" ]; then
$YAD2 --title="$TITLE" --form --notification --text="$EMSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
if  [ "$?" = "1" ]; then
"/usr/bin/steamapps-linker"
fi
exit 0
fi
$YAD2 --text="$MSG3 \n $LSAPP" --title=$"TITLE" --button="gtk-ok:0" --button="gtk-cancel:1" ret=$?
if [ "$?" = "1" ]; then
$YAD2 --title="$TITLE" --form --notification --text="$EMSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
if  [ "$?" = "1" ]; then
"/usr/bin/steamapps-linker"
fi
exit 0
fi
MFS="yes"
fi
fi

#Was manual selection used?
#==========================
if [ "$MFS" = "no" ]; then

#PlayOnLinux or Wine?
#====================
MSG=$"Did you install Steam with Wine or PlayOnLinux?"
$YAD2 --text="$MSG1" --title=$"Please select steamapps folder" --button="PlayOnLinux:1" --button="Wine:0" ret=$?
if [ "$?" = "1" ]; then

#Dose Steam exist in PlayOnLinux?
#================================
MSG=$"Couldn't find /home/$CUID/.PlayOnLinux/wineprefix/Steam/drive_c/Program Files/Steam."
if file "/home/$CUID/.PlayOnLinux/wineprefix/Steam/drive_c/Program Files/Steam"; then
LSAPP="/home/$CUID/.PlayOnLinux/wineprefix/Steam/drive_c/Program Files/Steam"
else
$YAD2 --text="$MSG" --title="$TITLE" --width=400 --button="gtk-ok:0"
$YAD2 --title="$TITLE" --form --notification --text="$EMSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
if  [ "$?" = "1" ]; then
"/usr/bin/steamapps-linker"
fi
exit 0
fi

else

#Dose Steam exist in Wine?
#=========================
MSG=$"Couldn't find /home/$CUID/.wine/drive_c/Program Files/Steam."
if file "/home/$CUID/.wine/drive_c/Program Files/Steam"; then
LSAPP="/home/$CUID/.wine/drive_c/Program Files/Steam"
else
$YAD2 --text="$MSG" --title="$TITLE" --width=400 --button="gtk-ok:0"
$YAD2 --title="$TITLE" --form --notification --text="$EMSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
if  [ "$?" = "1" ]; then
"/usr/bin/steamapps-linker"
fi
exit 0
fi
fi
fi

#Find out what is inside media folder
#====================================
MSG=$"Please select what media your Windows install is on"
MFS="no"
WSAM=`ls /media`
WSAM=$($YAD2 --title=$"TITLE" --text="$MSG" --entry $WSAM --button="gtk-ok:0" --button="None:1") ret=$?
if [ "$?" = "1" ]; then

#File destination
#================
MSG=$"Please select your Windows steamapps directory"
MSG2=$"For 32-bit most likly \n /media/disk/Program Files (x86)/Steam/steamapps \n \n For 64-bit most likly \n /media/disk/Program Files/Steam/steamapps"
MSG3=$"Contents of the directory you have chosen is:"
WSAPP=$($YAD2 --file --title="$TITLE" --width 800 --height 600 --button="gtk-ok:0" --button="gtk-cancel:1") ret=$?
if [ "$?" = "1" ]; then
$YAD2 --title="$TITLE" --form --notification --text="$EMSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
if  [ "$?" = "1" ]; then
"/usr/bin/steamapps-linker"
fi
exit 0
fi
$YAD2 --text="$MSG3 \n $WSAPP" --title=$"TITLE" --button="gtk-ok:0" --button="gtk-cancel:1" ret=$?
if [ "$?" = "1" ]; then
$YAD2 --title="$TITLE" --form --notification --text="$EMSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
if  [ "$?" = "1" ]; then
"/usr/bin/steamapps-linker"
fi
exit 0
fi
MFS="yes"
fi

#Was manual selection used?
#==========================
if [ "$MFS" = "no" ]; then

#32 or 64-bit?
#=============
if file /media/$WSAM/"Program Files/Steam"; then
WSAPP=$"/media/$WSAM/Program Files/Steam"
else
WSAPP=$"/media/$WSAM/Program Files (x86)/Steam"
fi
fi

#Confirm user imputs
#===================
MSG=$"Link Windows steamapps:"
MSG2=$"To Linux steamapps:"
MSG3=$"Is this correct?"
$YAD2 --text "$MSG \n $WSAPP \n \n $MSG2 \n $LSAPP \n \n $MSG3" --button="gtk-yes:0" --button="gtk-no:1" ret=$?
if [ "$?" = "1" ]; then
$YAD2 --title="$TITLE" --form --notification --text="$EMSG" --button="restart:1" --button="gtk-close:0" --sticky --fixed --on-top ret=$?
if  [ "$?" = "1" ]; then
"/usr/bin/steamapps-linker"
fi
exit 0
fi


#Symbolic link command
#=====================
rm -r "$LSAPP/steamapps_o"
y
mv "$LSAPP/steamapps" "$LSAPP/steamapps_o"
ln -s "$WSAPP/steamapps" "$LSAPP/steamapps"


#Confirmation
#============
MSG=$"Thank You for using steamapps-linker, please go to http://www.pclinuxos.com/forum and glamdring for support/errors \n Thank You"
$YAD2 --text "$MSG" --button="Restart:1" --button="Thank You:0"
if [ "$?" = "1" ]; then
"/usr/bin/shortcut-maker"
exit 0
fi

CURRENT QUESTIONS - 1

1.)How can I make sure any extra media spins up/mounts?
« Last Edit: November 06, 2011, 01:40:56 PM by glamdring »

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker
« Reply #1 on: November 05, 2011, 07:37:07 PM »
[SOLVED] I can't get the command to find out if directory exist to work.


I found a fix to my first problem! Unfortunately in all the internet I could fined a viable solution, so i played around some and found a way. So for anyone else who may look for this I will post it:
Code: [Select]
#!/bin/sh
if file /home; then

echo Yes

else

echo No
fi

Second solution:
Code: [Select]
if [ -d /home ]; then

 echo "Directory exists"
 
else

 echo "Directory does not exists"
 
fi

Because I removed the problem form the first post I will put it here for those who might be using the search:
« Last Edit: November 06, 2011, 07:15:55 AM by glamdring »

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker
« Reply #2 on: November 05, 2011, 08:12:43 PM »
[SOLVED] How can I get more than one option in a if statement?

I add a variable that is set to a value and changed at the end of a if statement that is executed, before starting the next operation it would check what that variable was set too. This gives me limitless ability of mixing whether or not to run a command.

Example:
Code: [Select]
#!/bin/sh
#Say woohoo
#============
SWH="no"
yad --text="Should we say whoohoo?" --button="gtk-yes:1" --button="gtk-no:0" ret=$?
if [ $? = 1 ]; then
yad --text="woohoo"
SWH="yes"
fi

#Did we say woohoo?
#===================
if [ "$SWH" = "no" ]; then
yad --text="D'oh"
fi

For user search purposes I left this here.
« Last Edit: November 06, 2011, 07:16:10 AM by glamdring »

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker
« Reply #3 on: November 05, 2011, 08:32:13 PM »
How can I make sure any extra media is spun up and or mounted? My script looks for media in the media folder, but if it's not spun up/mounted it doesn't see it. For example I can see my entire HDD in file viewer, but until I click on it once every so often my script can't see it.

Code I'm using to look for media:
Code: [Select]
#Find out what is inside media folder
#====================================
MSG=$"Please select what media your Windows install is on"
WSAM=`ls /media`
WSAM=$($YAD2 --title=$"TITLE" --text="$MSG" --entry $WSAM) --button="gtk-ok:0" --button="None:1" ret=$?

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: steamapps-linker
« Reply #4 on: November 06, 2011, 12:41:51 PM »
How can I make sure any extra media is spun up and or mounted? My script looks for media in the media folder, but if it's not spun up/mounted it doesn't see it. For example I can see my entire HDD in file viewer, but until I click on it once every so often my script can't see it.

Code I'm using to look for media:
Code: [Select]
#Find out what is inside media folder
#====================================
MSG=$"Please select what media your Windows install is on"
WSAM=`ls /media`
WSAM=$($YAD2 --title=$"TITLE" --text="$MSG" --entry $WSAM) --button="gtk-ok:0" --button="None:1" ret=$?


Basically you need to evaluate all block devices under /sys/block and understand which drive are removable, 
once identified mount each one, once at a time, and perform your own processing.

This thread should answer (mostly) your question:
http://www.pclinuxos.com/forum/index.php/topic,88410.msg738909.html#msg738909

The answer is mostly in this post:
http://www.pclinuxos.com/forum/index.php/topic,88410.msg743335.html#msg743335

If something is not clear, please ask.  ;)

AS


Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker
« Reply #5 on: November 06, 2011, 01:35:31 PM »

Basically you need to evaluate all block devices under /sys/block and understand which drive are removable, 
once identified mount each one, once at a time, and perform your own processing.

This thread should answer (mostly) your question:
http://www.pclinuxos.com/forum/index.php/topic,88410.msg738909.html#msg738909

The answer is mostly in this post:
http://www.pclinuxos.com/forum/index.php/topic,88410.msg743335.html#msg743335

If something is not clear, please ask.  ;)

AS


When using this it returns nothing, so I tried just using sfdisk -s in terminal and it returns "0 blocks"

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: steamapps-linker
« Reply #6 on: November 06, 2011, 01:49:56 PM »
When using this it returns nothing, so I tried just using sfdisk -s in terminal and it returns "0 blocks"

which type of external/internal media are you using ? IDE/SATA ? USB ? eSATA ?

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker (Looking for testers)
« Reply #7 on: November 06, 2011, 02:46:33 PM »
SATA

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: steamapps-linker (Looking for testers)
« Reply #8 on: November 06, 2011, 02:51:45 PM »
SATA

please try the following two commands:

ls -1 /sys/block/*/removable   # (and yes it is: ls -1=list -one)
cat /sys/block/*/removable

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker (Looking for testers)
« Reply #9 on: November 06, 2011, 02:59:38 PM »
Code: [Select]
[glamdring@localhost Documents]$ ls -1 /sys/block/*/removable   # (and yes it is: ls -1=list -one)
/sys/block/ram0/removable
/sys/block/ram10/removable
/sys/block/ram11/removable
/sys/block/ram12/removable
/sys/block/ram13/removable
/sys/block/ram14/removable
/sys/block/ram15/removable
/sys/block/ram1/removable
/sys/block/ram2/removable
/sys/block/ram3/removable
/sys/block/ram4/removable
/sys/block/ram5/removable
/sys/block/ram6/removable
/sys/block/ram7/removable
/sys/block/ram8/removable
/sys/block/ram9/removable
/sys/block/sda/removable
/sys/block/sr0/removable
[glamdring@localhost Documents]$ cat /sys/block/*/removable
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: steamapps-linker (Looking for testers)
« Reply #10 on: November 06, 2011, 03:02:28 PM »
/sys/block/sda/removable

is this the only disk actually connected/plugged in in your system ?

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker (Looking for testers)
« Reply #11 on: November 06, 2011, 03:04:46 PM »
I do indeed only have on disk connected: 1 SATA 500GB split with Windows and Linux

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: steamapps-linker (Looking for testers)
« Reply #12 on: November 06, 2011, 03:24:04 PM »
I do indeed only have on disk connected: 1 SATA 500GB split with Windows and Linux

OK,

@Just18,
first things to note is that sfdisk is not working here, please take good note about that.
EDIT: root permission was required

spin up/mount:

spin up can refer only to device, meaning a whole disk.
mount refer to partition(s)

In your case you need to mount the partition, and therefore you need:
a) to select one partition, of some supported type (NTFS, FAT32, ...)
b) mount the partition somewhere, say to /mnt
c) test the content of /mnt for file/dirs you are searching for

Code: [Select]
# a command like follow, will provide a list of the NTFS and FAT32 partitions
TEST_PART=`fdisk -l | egrep "NTFS|FAT32" | cut -d" " -f 1`
echo $TEST_PART
#
#
for PART in $TEST_PART
do
   mount $PART /mnt
   #####################
   #
   # perform you own test here
   # i.e.:
   echo $PART
   ls /mnt
   echo "\n\n"
   #
   #####################
   sleep 2
   umount $PART
done



« Last Edit: November 06, 2011, 05:42:17 PM by as »

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: steamapps-linker (Looking for testers)
« Reply #13 on: November 06, 2011, 03:38:40 PM »
the following should work  ;)

Quote
#Find out what is inside media folder
#====================================
MSG=$"Please select what media your Windows install is on"
WSAM=`fdisk -l | egrep "NTFS|FAT32" | cut -d" " -f 1`
WSAM=$($YAD2 --title=$"TITLE" --text="$MSG" --entry $WSAM) --button="gtk-ok:0" --button="None:1" ret=$?

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: steamapps-linker (Looking for testers)
« Reply #14 on: November 06, 2011, 03:58:18 PM »
the following should work  ;)

Quote
#Find out what is inside media folder
#====================================
MSG=$"Please select what media your Windows install is on"
WSAM=`fdisk -l | egrep "NTFS|FAT32" | cut -d" " -f 1`
WSAM=$($YAD2 --title=$"TITLE" --text="$MSG" --entry $WSAM) --button="gtk-ok:0" --button="None:1" ret=$?

Won't report any media for some reason, even just fdisk -l doesn't report anything. If I can simply make it access the disk it than can be seen, for example clicking on my windows partition in Dolphin will allow it to be seen by list or manual file viewer.