Fixed a few things

This commit is contained in:
Tristan Ancelet 2024-10-24 20:53:32 -05:00
parent 1e53f004f7
commit 77eb648a9a

View File

@ -32,7 +32,7 @@ class Dir
end end
## For backwards compat ## For backwards compat
def chdir(dir = nil &block) def chdir(dir = nil, &block)
if dir.nil? if dir.nil?
Dir.chdir(self, &block) Dir.chdir(self, &block)
else else
@ -61,8 +61,8 @@ File.mkdir($CONFIG[:icon_dir]) if not File.exist?($CONFIG[:icon_dir])
$CONFIG[:discord_config_path] = Dir.new(Dir.home) / '.config' / 'discord' $CONFIG[:discord_config_path] = Dir.new(Dir.home) / '.config' / 'discord'
$CONFIG[:local_application_install_dir] = Dir.new(Dir.home) / '.local' / 'share' / 'applications' $CONFIG[:local_application_install_dir] = Dir.new(Dir.home) / '.local' / 'share' / 'applications'
File.mkdir($CONFIG[:local_application_install_dir]) if not File.exist?($CONFIG[:local_application_install_dir]) File.mkdir($CONFIG[:local_application_install_dir]) if not File.exist?($CONFIG[:local_application_install_dir])
$CONFIG[:desktop_path] = Dir.new(Dir.home) / '.local' / 'share' / 'applications' / 'discord.desktop'
$CONFIG[:install_dir] = Dir.new(Dir.home) / '.opt' $CONFIG[:install_dir] = Dir.new(Dir.home) / '.opt'
$CONFIG[:desktop_path] = $CONFIG[:install_dir] / 'Discord' / 'discord.desktop'
File.mkdir($CONFIG[:install_dir]) if not File.exist?($CONFIG[:install_dir]) File.mkdir($CONFIG[:install_dir]) if not File.exist?($CONFIG[:install_dir])
$CONFIG[:discord_path] = $CONFIG[:install_dir] / 'Discord' $CONFIG[:discord_path] = $CONFIG[:install_dir] / 'Discord'
$CONFIG[:desktop_file_path] = $CONFIG[:discord_path] / 'discord.desktop' $CONFIG[:desktop_file_path] = $CONFIG[:discord_path] / 'discord.desktop'
@ -76,11 +76,11 @@ Name=Discord
StartupWMClass=discord StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone. Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger GenericName=Internet Messenger
Exec=#{$CONFIG[:install_dir].path}/Discord/Discord Exec=#{$CONFIG[:discord_dir]}/Discord
Icon=discord Icon=discord
Type=Application Type=Application
Categories=Network;InstantMessaging; Categories=Network;InstantMessaging;
Path=#{$CONFIG[:install_dir].path}/Discord Path=#{$CONFIG[:discord_path]}
EOF EOF
# END: Variables # END: Variables
@ -104,6 +104,7 @@ OptionParser.new do |parser|
parser.on('-u', '--uninstall', "Uninstall Discord (not-implemented)") do parser.on('-u', '--uninstall', "Uninstall Discord (not-implemented)") do
$CONFIG[:action] = 'uninstall' $CONFIG[:action] = 'uninstall'
$CONFIG[:backup_filename] = Dir.home / 'discord-backup-' + Time.now.strftime('%Y-%m-%d') + '.tar.gz'
end end
parser.on('-b', '--backup [FILENAME]', "Backup Discord Installation") do |backup_filename| parser.on('-b', '--backup [FILENAME]', "Backup Discord Installation") do |backup_filename|
@ -127,7 +128,7 @@ OptionParser.new do |parser|
$CONFIG[:debug] = true $CONFIG[:debug] = true
end end
parser.on('--keep', 'Keep discord tar.gz file (default: False)') do parser.on('--keep', "Keep discord tar.gz file (default: #{$CONFIG[:keep_installer].to_s})") do
$CONFIG[:keep_installer] = true $CONFIG[:keep_installer] = true
end end
@ -200,9 +201,12 @@ class Installer
File.unlink(installer_file) File.unlink(installer_file)
end end
end end
update_desktop_file
end end
end end
# END: Helper Classes # END: Helper Classes