Skip to content

Instantly share code, notes, and snippets.

@olaioo
Last active July 27, 2021 20:04
Show Gist options
  • Select an option

  • Save olaioo/c6754220f6bbfc162d3fdfaab6ea2656 to your computer and use it in GitHub Desktop.

Select an option

Save olaioo/c6754220f6bbfc162d3fdfaab6ea2656 to your computer and use it in GitHub Desktop.
A shell script to reset eval time of Intellij IDEA before it ends.
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = intellij-idea-ultimate-edition*
[Action]
Description = Injecting resetScript.sh in idea.sh
When = PostTransaction
Depends = intellij-idea-ultimate-edition
Exec = /usr/bin/sed -i '/^# Run the IDE..*/i # Reset eval time of the IDE.\n# ---------------------------------------------------------------------\nsh $IDE_BIN_HOME/resetScript.sh\n\n# ---------------------------------------------------------------------' /opt/intellij-idea-ultimate-edition/bin/idea.sh

Reset IDEA (Linux ONLY)

Instructions

First, paste/create the file resetScript.sh into your IDEA's instalation folder (example: /opt/intellij-idea-ultimate-edition/bin/)

After, edit the file idea.sh that you can locate at the same directory. And add these line before the commented line, # Run the IDE.

sh $IDE_BIN_HOME/resetScript.sh

The end of your idea.sh file should be like, this:

...

# ---------------------------------------------------------------------
# Reset eval time of the IDE.
# ---------------------------------------------------------------------
sh $IDE_BIN_HOME/resetScript.sh

# ---------------------------------------------------------------------
# Run the IDE.
# ---------------------------------------------------------------------
IFS="$(printf '\n\t')"
# shellcheck disable=SC2086
"$JAVA_BIN" \
  -classpath "$CLASSPATH" \
  ${VM_OPTIONS} \
  "-XX:ErrorFile=$HOME/java_error_in_idea_%p.log" \
  "-XX:HeapDumpPath=$HOME/java_error_in_idea_.hprof" \
  "-Didea.vendor.name=${PRODUCT_VENDOR}" \
  "-Didea.paths.selector=${PATHS_SELECTOR}" \
  "-Djb.vmOptionsFile=$VM_OPTIONS_FILE" \
  ${IDE_PROPERTIES_PROPERTY} \
  -Didea.jre.check=true \
  com.intellij.idea.Main \
  "$@"

Now, your eval time should be reseted before it ends. You just need to select Evaluate for free again, when it resets. If you're using Arch Linux, you can use the hook file for automatically inject the resetScript.sh when it upgrades, it should be placed in /etc/pacman.d/hooks/.

eval_time=$((86400 * 29))
eval_date=$(date -r ~/.java/.userPrefs/jetbrains/idea +%s)
eval_date=$(($eval_date + eval_time))
now_date=$(date +%s)
if [ $now_date -gt $eval_date ]
then
echo "Reseting..."
rm -rf ~/.config/JetBrains/IntelliJIdea*/eval
sed -i -E 's/<property name=\"evl.*\".*\/>//' ~/.config/JetBrains/IntelliJIdea*/options/other.xml
rm -rf ~/.java/.userPrefs/jetbrains/idea
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment